Skip to content

Instantly share code, notes, and snippets.

@sangheestyle
Created November 27, 2014 12:35
Show Gist options
  • Save sangheestyle/be928ea8c58a2b34aaf9 to your computer and use it in GitHub Desktop.
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
#!/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
@sangheestyle
Copy link
Author

$ git log --pretty=format: --name-only | sort | uniq -c | sort -rg | head -10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment