Debian Codegraph @

utils/revlist2humantest.bash

raw
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
9 set -e
10
11 repo=`git remote show origin | grep Fetch | cut -d' ' -f5`
12 branch=`git branch | egrep '^\* .*' | cut -d' ' -f2`
13 if [ "$#" -eq 1 ] ; then
14 commit=`git log | head -1 | cut -d' ' -f2`
15 path=$1
16 elif [ "$#" -eq 2 ] ; then
17 commit=$1
18 path=$2
19 else
20 echo "bad number of parameters" > /dev/stderr
21 echo > /dev/stderr
22 echo " try with: [commit] path" > /dev/stderr
23 exit
24 fi
25
26 hashes=`git rev-list --remove-empty --reverse $commit -- $path`
27
28 # some remotes have the .git, other don't,
29 # repoDot makes sure all have
30 repoDot="${repo%.git}.git"
31
32 echo -e "\t&humanTest{\"${repoDot}\", \"${branch}\", \"${commit}\", \"${path}\", []string{"
33 for i in $hashes ; do
34 echo -e "\t\t\"${i}\","
35 done
36 echo -e "\t}},"