Last active
August 13, 2021 16:18
-
-
Save SeanFelipe/9d047da7873dd2624bc0505ceb8eeab6 to your computer and use it in GitHub Desktop.
pre-commit script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'paint/pa' | |
pa "running pre git checks from #{Dir.pwd}/pre_git_checks ...", :gray | |
class DeleteCodeError < RuntimeError; end | |
def ags(tag) | |
#res = `unbuffer ag #{tag}` | |
res = `ag #{tag}` | |
if res == '' | |
return [] | |
else | |
fn = res.split(':').first | |
return [ fn ] | |
end | |
end | |
swlib = ags('swlib') | |
if swlib.length > 0 | |
raise DeleteCodeError, "found swlib: #{swlib}" | |
end | |
set_trace = ags('set_trace') | |
if set_trace.length > 0 | |
raise DeleteCodeError, "found set_trace: #{set_trace}" | |
end | |
message = ARGV[2] | |
pa 'pre_git_checks success, proceeding with commit ...', :gray | |
puts | |
pa "gcm message: \"#{message}\"", :gray | |
puts | |
cmd = 'git commit -m "' | |
cmd += message | |
cmd += '"' | |
exec cmd | |
pa 'pre_git_checks: git commit complete.', :gray |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment