aboutsummaryrefslogtreecommitdiffstats
path: root/blame/blame2humantest.bash
diff options
context:
space:
mode:
authorAlberto Cortés <alberto@sourced.tech>2015-11-16 03:20:01 +0100
committerAlberto Cortés <alberto@sourced.tech>2015-11-25 11:09:51 +0100
commitd643cea1e8a6d618b2eddfdbed086c7bdf208658 (patch)
treeb862c72ccb674910d24eac2ab424a7fb5ea3f0fb /blame/blame2humantest.bash
parentcaab43e7f4ee10a15b2af826485b688473b34356 (diff)
downloadgo-git-d643cea1e8a6d618b2eddfdbed086c7bdf208658.tar.gz
Blame support for files
This also includes a diff package and revlist package (needed by blame) Some extra packfiles (<1MB) are also included, to be used as fixtures in the tests.
Diffstat (limited to 'blame/blame2humantest.bash')
-rwxr-xr-xblame/blame2humantest.bash47
1 files changed, 47 insertions, 0 deletions
diff --git a/blame/blame2humantest.bash b/blame/blame2humantest.bash
new file mode 100755
index 0000000..259988f
--- /dev/null
+++ b/blame/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)},"