Skip to content

Commit

Permalink
Merge pull request #37 from smartcitiesdata/pre_commit
Browse files Browse the repository at this point in the history
Add pre commit hook script to check credo, format, and deps versions
  • Loading branch information
dickthedev authored Jun 28, 2019
2 parents e29d156 + e6d0ce9 commit 8f7d983
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
2 changes: 1 addition & 1 deletion config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
38 changes: 38 additions & 0 deletions scripts/git_pre_commit_hook.sh
Original file line number Diff line number Diff line change
@@ -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
13 changes: 0 additions & 13 deletions scripts/set_release_number.sh

This file was deleted.

0 comments on commit 8f7d983

Please sign in to comment.