aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2015-12-12 22:07:47 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2015-12-12 22:07:47 +0100
commitf821e1340752dce95f73375dc9a13dcd58d58f82 (patch)
treed68b7e33aba06f67d3c3e301b4a68f09de0ded6a /utils
parentc22c181f70e0afb294513315e9975b9f3f4c1d39 (diff)
parentb543e4e02793a58db25148214ef149cb571792f5 (diff)
downloadgo-git-f821e1340752dce95f73375dc9a13dcd58d58f82.tar.gz
Merge pull request #9 from mcuadros/blame-cleanupv2.0.0
blame code reorganization, and mutting the test
Diffstat (limited to 'utils')
-rwxr-xr-xutils/blame2humantest.bash47
-rwxr-xr-xutils/revlist2humantest.bash36
2 files changed, 83 insertions, 0 deletions
diff --git a/utils/blame2humantest.bash b/utils/blame2humantest.bash
new file mode 100755
index 0000000..259988f
--- /dev/null
+++ b/utils/blame2humantest.bash
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+set -e
+
+repo=`git remote show origin | grep Fetch | cut -d' ' -f5`
+branch="master"
+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
+
+blames=`git blame --root $path | cut -d' ' -f1`
+declare -a blame
+i=0
+for shortBlame in $blames ; do
+ blame[$i]=`git show $shortBlame | head -1 | cut -d' ' -f2`
+ i=`expr $i + 1`
+done
+
+# some remotes have the .git, other don't,
+# repoDot makes sure all have
+repoDot="${repo%.git}.git"
+
+echo -e "\t{\"${repoDot}\", \"${branch}\", \"${commit}\", \"${path}\", concat(&[]string{},"
+prev=""
+count=1
+for i in ${blame[@]} ; do
+ if [ "${prev}" == "" ] ; then
+ prev=$i
+ elif [ "$prev" == "$i" ] ; then
+ count=`expr $count + 1`
+ else
+ echo -e "\t\trepeat(\"${prev}\", $count),"
+ count=1
+ prev=$i
+ fi
+done
+echo -e "\t\trepeat(\"${prev}\", $count),"
+echo -e "\t)},"
diff --git a/utils/revlist2humantest.bash b/utils/revlist2humantest.bash
new file mode 100755
index 0000000..b7d2672
--- /dev/null
+++ b/utils/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}},"