Skip to content

Instantly share code, notes, and snippets.

@avandrevitor
Created August 17, 2018 17:15
Show Gist options
  • Save avandrevitor/6a60b2bfef4d1dd9af2427965ac6a611 to your computer and use it in GitHub Desktop.
Save avandrevitor/6a60b2bfef4d1dd9af2427965ac6a611 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
our_secret = "aaaa"
params = gets
oldref = params.split()[0]
newref = params.split()[1]
refname = params.split()[2]
changed_files = `git diff --no-commit-id --name-only #{oldref}..#{newref}`
if changed_files.include? '.gitlab-ci.yml' then
commit_messages = `git log --pretty=%s #{newref} | head -3`.split("\n")
unless commit_messages.include? our_secret
puts "================================================================= "
puts "██████╗ ███████╗ ██╗███████╗ ██████╗████████╗███████╗██████╗ "
puts "██╔══██╗██╔════╝ ██║██╔════╝██╔════╝╚══██╔══╝██╔════╝██╔══██╗ "
puts "██████╔╝█████╗ ██║█████╗ ██║ ██║ █████╗ ██║ ██║ "
puts "██╔══██╗██╔══╝ ██ ██║██╔══╝ ██║ ██║ ██╔══╝ ██║ ██║ "
puts "██║ ██║███████╗╚█████╔╝███████╗╚██████╗ ██║ ███████╗██████╔╝ "
puts "╚═╝ ╚═╝╚══════╝ ╚════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚══════╝╚═════╝ "
puts "================================================================= "
puts ""
puts " oldref is #{oldref}"
puts " newref is #{newref}"
puts " refname is #{refname}"
puts " "
puts " We are very very sorry but your change seems to violate our policies! "
puts " Please check with your nearest Guru! :) ERROR_ID: 001 "
puts "================================================================= "
exit 1
end
end # if changed_files.include?
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment