Created
October 29, 2019 08:49
-
-
Save sergio-fry/5fbae12d072e482e38240b08cc4f4548 to your computer and use it in GitHub Desktop.
Git message generator
This file contains hidden or 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 | |
# frozen_string_literal: true | |
last_comment = `git log --pretty=oneline --abbrev-commit | head -n 1`.split("\n").first | |
def generate_message(n) | |
"changes ##{n} at #{Time.now.strftime "%H:%M:%S %a %d.%m.%y"}" | |
end | |
message = if last_comment.nil? | |
generate_message 1 | |
elsif m = last_comment.match(/changes #(\d+)/) | |
generate_message m[1].to_i + 1 | |
else | |
generate_message 1 | |
end | |
puts message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment