Skip to content

Instantly share code, notes, and snippets.

@kaushikgopal
Last active August 29, 2015 13:56
Show Gist options
  • Save kaushikgopal/8950126 to your computer and use it in GitHub Desktop.
Save kaushikgopal/8950126 to your computer and use it in GitHub Desktop.
Git script to check changes to a file since last tagged release
#!/usr/bin/env ruby
require 'optparse'
tag_name = %x[git tag | tail -1].strip
optparse = OptionParser.new
optparse.parse!
filename = ARGV.pop
puts "\n"
puts "---------------------------------------\n"
puts "LAST RELEASE - \033[1;35m#{tag_name}\033[0m"
changes = %x[git ll #{tag_name}.. #{filename}]
num_of_changes = changes.lines.count
puts "#{num_of_changes} changes so far\n"
puts "---------------------------------------\n"
puts "#{changes}\n\n" if num_of_changes > 0
=begin
# my git alias for ll
[alias]
ll = !git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
# I alias this script to gcheck. So i run the file like so:
$> gcheck my/git/file/in/repo/SomeActivity.java
---------------------------------------
LAST RELEASE - android_release_X-X-X
1 changes so far
---------------------------------------
* qh51d30 - fix: random fix to test git script (18 hours ago) <Kaushik Gopal>
=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment