diff --git a/README.md b/README.md index 1186d7a..8472289 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The package can be installed by adding `divo` to your list of dependencies in `m ```elixir def deps() do [ - {:divo, "~> 1.1.5", only: [:dev, :integration]} + {:divo, "~> 1.1.8", only: [:dev, :integration]} ] end ``` diff --git a/config/dev.exs b/config/dev.exs index eb21d14..82ce7b9 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -23,4 +23,4 @@ config :divo, } config :husky, - pre_commit: "mix format --check-formatted && mix credo && mix hex.outdated" + pre_commit: "./scripts/git_pre_commit_hook.sh" diff --git a/mix.exs b/mix.exs index 597b76d..d122afc 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule Divo.MixProject do def project do [ app: :divo, - version: "1.1.7", + version: "1.1.8", elixir: "~> 1.8", start_permanent: Mix.env() == :prod, deps: deps(), diff --git a/scripts/git_pre_commit_hook.sh b/scripts/git_pre_commit_hook.sh new file mode 100755 index 0000000..9843e47 --- /dev/null +++ b/scripts/git_pre_commit_hook.sh @@ -0,0 +1,38 @@ +#! /bin/bash +RED='\033[0;31m' +NC='\033[0m' # No Color +exit_code=0 + +#Check that version in README.md matches what is in mix.exs +build_output=$(mix hex.build) +current_version=$(echo "$build_output" | grep 'Version:' | awk '{print $2}') +app_name=$(echo "$build_output" | grep 'Building' | awk '{print $2}') +grep -q "{:$app_name, \"~> $current_version" README.md +if [ $? == 1 ]; then + echo -e "${RED}Update the version number in README.md to $current_version\r\n" + exit_code=1 +fi + +mix format + +echo -e "${NC}mix credo - compiling code there may be a delay" +compile_output=$(mix compile 2>/dev/null) ##Supress compile output and warnings + +credo_output=$(mix credo --format=oneline) +if [ $? != 0 ]; then + echo -e "${RED}$credo_output${NC}\r\n" + exit_code=1 +fi + +outdated_output=$(mix hex.outdated) +if [ $? == 1 ]; then + echo -e "${NC}Outdated dependencies" + echo -e "$outdated_output" | grep "Dependency" + echo -en "${RED}" + echo -e "$outdated_output" | grep " No" + echo -e "$outdated_output" | grep " Yes" + echo -e "${NC}" + exit_code=1 +fi + +exit $exit_code \ No newline at end of file diff --git a/scripts/set_release_number.sh b/scripts/set_release_number.sh deleted file mode 100755 index 8404ff4..0000000 --- a/scripts/set_release_number.sh +++ /dev/null @@ -1,13 +0,0 @@ -#! /bin/bash -current_version=$(mix hex.build | grep 'Version:' | awk '{print $2}') -echo "Current Application Version is: " $current_version -read -p "Enter new version number: " new_version -files=( - mix.exs - README.md -) -for file in "${files[@]}"; do - sed -i '' "s/$current_version/$new_version/g" "$file" -done - -echo "You will need commit the changed files"