Skip to content

Instantly share code, notes, and snippets.

@DmytroVasin
Last active August 29, 2015 14:16
Show Gist options
  • Save DmytroVasin/ac55b0a8e09ec1fa025e to your computer and use it in GitHub Desktop.
Save DmytroVasin/ac55b0a8e09ec1fa025e to your computer and use it in GitHub Desktop.
GIT: .git/hooks/pre-push (executive permitions)
#!/usr/bin/env ruby
current_branch = `git symbolic-ref --short HEAD`.to_s.strip!
first_preproduction_sha = `git merge-base #{current_branch} preproduction`
first_master_sha = `git merge-base #{current_branch} master`
preproduction_timestamp = `git show -s --format=%ci #{first_preproduction_sha}`
master_timestamp = `git show -s --format=%ci #{first_master_sha}`
if master_timestamp > preproduction_timestamp
puts "\033[31mИдиот - ты начал ветку с мастера. Продолжать?\033[0m"
puts "\033[32m[yes][╚➤]y\033[0m | \033[33m[no]n\033[0m"
STDIN.reopen('/dev/tty')
user_input = STDIN.gets.chomp!
STDIN.close
if ['y','yes',''].include?(user_input)
exit(0)
else
exit(1)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment