Last active
October 18, 2024 22:57
-
-
Save kosaki/24a36b98253fabfd4b92 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/ruby | |
require 'date' | |
changelog = nil | |
# find out ChangeLog file | |
diff = `git diff --stat HEAD` | |
diff.scan(/^ (ChangeLog) +\|/) { |ary| | |
changelog = ary[0] | |
} | |
# if no changelog, we don't need any modify | |
if changelog == nil then | |
exit 0 | |
end | |
str = `git diff HEAD #{changelog}` | |
if str =~ /^\+(\w.*)$/ then | |
date_str = $1 | |
end | |
# date_str example | |
# Fri Aug 15 10:13:37 2014 SHIBATA Hiroshi <[email protected]> | |
str =~ /.*\d\d:\d\d:\d\d \d\d\d\d (\w+(?: \w+)) +<(.+)>/ | |
name = $1 | |
email = $2 | |
d = DateTime.now.new_offset(Rational(9,24)) | |
replace = d.strftime("%a %b %e %H:%M:%S %Y") + " #{name} <#{email}>" | |
`sed -i -e "s/#{date_str}/#{replace}/" #{changelog}` | |
`git add #{changelog}` | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment