Created
September 10, 2012 04:01
-
-
Save hhutch/3688814 to your computer and use it in GitHub Desktop.
find file changes in all forks of a github repo
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
curl -i https://api.github.com/repos/scrooloose/nerdtree/forks |grep -e "git_url" |awk '{gsub(/,/,"");split($2,a,"/"); system("mkdir "a[4]"; cd "a[4]"; git clone " $2);}' |
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
DIRS=$(find * -type d -name '*nerdtree' -maxdepth 1 -print) | |
FILECHANGE="plugin/NERD_tree.vim" | |
for d in $DIRS | |
do | |
cd $d | |
git fetch | |
BRANCHES=$(git branch -a) | |
OBS=$(git branch -r |egrep -v '(HEAD)') | |
for ob in $OBS | |
do | |
git checkout -t $ob 2>/dev/null | |
bonly=$(echo $ob |awk {'split($0,a,"/"); print a[2]'}) | |
git checkout $bonly &>/dev/null | |
git pull &>/dev/null | |
out=$(git log --pretty=format:"%H %ad" $FILECHANGING |head -n1 | xargs -I{} echo `pwd`"("$ob"): "{}) | |
echo $out | |
done | |
cd ../.. | |
done |
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
#1 mkdir $working_dir; echo "modify fetch-repos.sh for your source repo"; cd $working_dir; bash fetch-repos.sh; | |
#2 echo "modify find-file-changes.sh to use the file you need"; cd $working_dir; bash find-file-changes.sh > all-branch-changes.txt | |
#3 cat all-branch-changes.txt |sort -k4M,7 | |
This will output a list of fork:branche:commit for a specific file sorted by date of commit; | |
Note: this is kind of brittle and could break depending on the input data (ie the names of things in the repositories). | |
I had a different use case. I needed to output all the diffs for a given file. Here follows my solution. It replaces the find-file-changes.sh
DIRS=$(find * -type d -name 'J2M' -maxdepth 2 -print)
FILECHANGE="index.js"
ORIGINAL=https://github.com/kylefarris/J2M.git
for d in $DIRS
do
cd $d
git fetch
git remote add original $ORIGINAL
git fetch original
CURR_REP=$(pwd | rev | cut -f2 -d'/' - | rev)
echo output to $CURR_REP
git diff --ignore-cr-at-eol --ignore-space-at-eol -b -w --ignore-blank-lines HEAD original/master index.js --output=../../$CURR_REP.diff
cd ../..
done
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks. This helps immensely!. Though the find gives errors sometimes. This is a better option:
DIRS=$(find . -maxdepth 2 -type d -name '*nerdtree' -print)