Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/mix/tasks/pre_commit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ defmodule Mix.Tasks.PreCommit do

def run(_) do
IO.puts "\e[95mPre-commit running...\e[0m"
{_, 0} = System.cmd("git", String.split("stash push --keep-index --message pre_commit", " "))

@commands
|> Enum.each(&run_cmds/1)

{_, 0} = System.cmd("git", String.split("stash pop", " "))
IO.puts "\e[32mPre-commit passed!\e[0m"
System.halt(0)
end
Expand All @@ -37,6 +39,7 @@ defmodule Mix.Tasks.PreCommit do
{result, _} ->
if !@verbose, do: IO.puts result
IO.puts "\e[31mPre-commit failed on `mix #{cmd}`.\e[0m \nCommit again with --no-verify to live dangerously and skip pre-commit."
{_, 0} = System.cmd("git", String.split("stash pop", " "))
System.halt(1)
end
end
Expand Down