Skip to content

Instantly share code, notes, and snippets.

@skylerto
Created September 19, 2016 16:45
Show Gist options
  • Save skylerto/bb260baeba9ae4a06ae5c14fb300d74b to your computer and use it in GitHub Desktop.
Save skylerto/bb260baeba9ae4a06ae5c14fb300d74b to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
class Commit
attr_accessor :hash, :message
def initialize commit
line = commit.split(" ")
@hash = line[0]
@message = line[1..(line.size)].join(" ")
end
def to_s
"Hash: #{@hash}, Message: #{@message}"
end
end
searchMessage = "AUTO COMMIT"
branch = %x(git rev-parse --abbrev-ref HEAD).delete!("\n")
status = %x(git log origin/#{branch}..#{branch} --grep='#{searchMessage}' --pretty=oneline --abbrev-commit)
commits = Array.new;
status.each_line do |line|
commit = Commit.new line
commits.push(commit)
end
if commits.size > 0
puts "Update commit messages before pushing"
commits.each do |commit|
puts commit
end
exit 1
else
exit 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment