Created
September 19, 2016 16:45
-
-
Save skylerto/bb260baeba9ae4a06ae5c14fb300d74b to your computer and use it in GitHub Desktop.
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 | |
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