Skip to content

Commit

Permalink
Add pre commit hook script to check credo, format, and deps versions
Browse files Browse the repository at this point in the history
co-authored-by: Scott Millard <smillard@hntb.com>
  • Loading branch information
dickthedev and Scott Millard committed Jul 1, 2019
1 parent e29d156 commit f6b80c1
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 17 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.9", 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.9",
elixir: "~> 1.8",
start_permanent: Mix.env() == :prod,
deps: deps(),
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"meck": {:hex, :meck, "0.8.13", "ffedb39f99b0b99703b8601c6f17c7f76313ee12de6b646e671e3188401f7866", [:rebar3], [], "hexpm"},
"nimble_parsec": {:hex, :nimble_parsec, "0.5.0", "90e2eca3d0266e5c53f8fbe0079694740b9c91b6747f2b7e3c5d21966bba8300", [:mix], [], "hexpm"},
"patiently": {:hex, :patiently, "0.2.0", "67eb139591e10c4b363ae0198e832552f191c58894731efd3bf124ec4722267a", [:mix], [], "hexpm"},
"placebo": {:hex, :placebo, "1.2.1", "303ebb597279fd77b1f6d38ec377be4932f73246351f181d6128d0a58d3f74e9", [:mix], [{:meck, "~> 0.8.9", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"},
"placebo": {:hex, :placebo, "1.2.2", "a3d47906b01844bfd04ab0351a605620619fdb8f011225e406696f96a88ff380", [:mix], [{:meck, "~> 0.8.13", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"},
"temporary_env": {:hex, :temporary_env, "2.0.1", "d4b5e031837e5619485e1f23af7cba7e897b8fd546eaaa8b10c812d642ec4546", [:mix], [], "hexpm"},
}
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 f6b80c1

Please sign in to comment.