aboutsummaryrefslogtreecommitdiffstats
path: root/revlist/revlist2humantest.bash
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2015-12-11 23:58:00 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2015-12-11 23:58:00 +0100
commitc22c181f70e0afb294513315e9975b9f3f4c1d39 (patch)
tree8377ae4645c58454d0f2a61631a4a81d2d7d5faf /revlist/revlist2humantest.bash
parent5c8fff7e9e614d9f463d964699539fe71509ba39 (diff)
parentc347e978b52212b5aa968a14d81c8fff47ab24d7 (diff)
downloadgo-git-c22c181f70e0afb294513315e9975b9f3f4c1d39.tar.gz
Merge pull request #7 from alcortesm/blame
Blame
Diffstat (limited to 'revlist/revlist2humantest.bash')
-rwxr-xr-xrevlist/revlist2humantest.bash36
1 files changed, 36 insertions, 0 deletions
diff --git a/revlist/revlist2humantest.bash b/revlist/revlist2humantest.bash
new file mode 100755
index 0000000..b7d2672
--- /dev/null
+++ b/revlist/revlist2humantest.bash
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+# you can run this over a whole repo with:
+#
+# for file in `find . -type f | sed 's/^\.\///' | egrep -v '^\.git\/.*$'` ; do revlist2humantest.bash $file ; done > /tmp/output
+#
+# be careful with files with spaces, though
+
+set -e
+
+repo=`git remote show origin | grep Fetch | cut -d' ' -f5`
+branch=`git branch | egrep '^\* .*' | cut -d' ' -f2`
+if [ "$#" -eq 1 ] ; then
+ commit=`git log | head -1 | cut -d' ' -f2`
+ path=$1
+elif [ "$#" -eq 2 ] ; then
+ commit=$1
+ path=$2
+else
+ echo "bad number of parameters" > /dev/stderr
+ echo > /dev/stderr
+ echo " try with: [commit] path" > /dev/stderr
+ exit
+fi
+
+hashes=`git rev-list --remove-empty --reverse $commit -- $path`
+
+# some remotes have the .git, other don't,
+# repoDot makes sure all have
+repoDot="${repo%.git}.git"
+
+echo -e "\t&humanTest{\"${repoDot}\", \"${branch}\", \"${commit}\", \"${path}\", []string{"
+for i in $hashes ; do
+ echo -e "\t\t\"${i}\","
+done
+echo -e "\t}},"