Created
November 27, 2014 12:35
-
-
Save sangheestyle/be928ea8c58a2b34aaf9 to your computer and use it in GitHub Desktop.
Get the scope of given class in a given file and hen show the evelution of the class via git log -L
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
#!/bin/bash | |
# Get the scope of given class in a given file | |
# Then show the evelution of the class via git log -L | |
# usage: show_scope [classname] [filename] | |
# cname='class HttpAuthHandler' | |
# fname='HttpAuthHandler.java' | |
cname=$1 | |
fname=$2 | |
begin=$(grep -n ".*$cname.*" $fname | grep -Eo "^[0-9]{1,5}") | |
num_lines=$(grep -zPo ".*$cname.*(\{([^{}]++|(?1))*\})" $fname | wc -l) | |
end=$((begin + num_lines - 1)) | |
git log -L $begin,$end:$fname |
Author
sangheestyle
commented
Nov 28, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment