Created
December 2, 2017 12:55
-
-
Save gouf/01b0c355ea1fe528fa9fdf998b07c1c1 to your computer and use it in GitHub Desktop.
「今日のローカルでの作業(コミット)」を、GitHub Compare URL 形式に加工する(※コミットは要 push)
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
#!/home/gouf/.anyenv/envs/rbenv/shims/ruby | |
# vim: ft=ruby | |
Dir.chdir(Dir.pwd) | |
# | |
# リポジトリ/ユーザ名の抽出 | |
# | |
origin = %x(git remote -v) | |
user_name_and_repository_name = %r{([^:/]+)/([^/]+)\(.+\)$} | |
user_name, repository_name = | |
origin.match(user_name_and_repository_name) | |
.captures | |
.map { |x| x.strip.gsub('.git', '') } | |
# | |
# 今日のローカルでのコミットを抽出 | |
# | |
# Ref: https://coderwall.com/p/7jbwww/git-today-quickly-see-what-you-ve-done-today | |
todays_commit = %x(git log --reverse --no-merges --branches=* --date=local --since=midnight --oneline --author="$(git config --get user.name)"|(head -n 1;tail -n 1)) | |
commit_a, commit_b = todays_commit.lines.map { |x| x.match(/^\w+/) } | |
puts %W[ | |
https://github.com/ | |
#{user_name}/ | |
#{repository_name}/ | |
compare/ | |
#{commit_a}...#{commit_b} | |
].join('') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment