-
-
Save viktor-evdokimov/d3b225c6bd91c57bc3b60565ffe1d4d0 to your computer and use it in GitHub Desktop.
git-reup
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 | |
# | |
# Usage: git-up | |
# git-reup | |
# | |
# Like git-pull but show a short and sexy log of changes | |
# immediately after merging (git-up) or rebasing (git-reup). | |
# | |
# Inspired by Kyle Neath's `git up' alias: | |
# http://gist.github.com/249223 | |
# | |
# Stolen from Ryan Tomayko | |
# http://github.com/rtomayko/dotfiles/blob/rtomayko/bin/git-up | |
# and then Zach Holman | |
# https://github.com/holman/dotfiles/blob/master/bin/git-up | |
# and then Barijaona Ramaholimihaso | |
# https://gist.github.com/barijaona/3194807 | |
require 'shellwords' | |
pull_args = ARGV.to_a | |
rebase = File.basename($0) == 'git-reup' | |
stashed = false | |
old_head = `git rev-parse HEAD`.chomp | |
exit($?.to_i) unless $? == 0 | |
if rebase | |
pull_args.push '--rebase' | |
msg = `git stash save "Auto-stash by #{File.basename($0)} script"` | |
stashed = msg !~ /^No local changes to save$/ | |
end | |
system "git pull #{pull_args.shelljoin}" | |
updated = (old_head != `git rev-parse HEAD`.chomp) | |
system "git stash pop --quiet" if stashed && rebase | |
if updated | |
if rebase | |
puts "Diffstat:" | |
system "git --no-pager diff --color --stat #{old_head}.. | sed 's/^/ /'" | |
end | |
puts "Log:" | |
system "git log --color --pretty=oneline --abbrev-commit #{old_head}.. | sed 's/^/ /'" | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment