Skip to content

Instantly share code, notes, and snippets.

@SeanFelipe
Last active August 13, 2021 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeanFelipe/9d047da7873dd2624bc0505ceb8eeab6 to your computer and use it in GitHub Desktop.
Save SeanFelipe/9d047da7873dd2624bc0505ceb8eeab6 to your computer and use it in GitHub Desktop.
pre-commit script
#!/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