1#!/bin/bash
2
3# you can run this over a whole repo with:
4#
5# for file in `find . -type f | sed 's/^\.\///' | egrep -v '^\.git\/.*$'` ; do revlist2humantest.bash $file ; done > /tmp/output
6#
7# be careful with files with spaces, though
8
9set -e
10
11repo=`git remote show origin | grep Fetch | cut -d' ' -f5`
12branch=`git branch | egrep '^\* .*' | cut -d' ' -f2`
13if [ "$#" -eq 1 ] ; then
14 commit=`git log | head -1 | cut -d' ' -f2`
15 path=$1
16elif [ "$#" -eq 2 ] ; then
17 commit=$1
18 path=$2
19else
20 echo "bad number of parameters" > /dev/stderr
21 echo > /dev/stderr
22 echo " try with: [commit] path" > /dev/stderr
23 exit
24fi
25
26hashes=`git rev-list --remove-empty --reverse $commit -- $path`
27
28# some remotes have the .git, other don't,
29# repoDot makes sure all have
30repoDot="${repo%.git}.git"
31
32echo -e "\t&humanTest{\"${repoDot}\", \"${branch}\", \"${commit}\", \"${path}\", []string{"
33for i in $hashes ; do
34 echo -e "\t\t\"${i}\","
35done
36echo -e "\t}},"