-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-rockstar
executable file
·69 lines (60 loc) · 1.63 KB
/
git-rockstar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
DIR=$( dirname $0 )
CONFIGURE_OUTPUT=$DIR/.configure_output
$DIR/configure > $CONFIGURE_OUTPUT
STATUS=$?
if [ "$STATUS" -ne 0 ]; then
echo "Cannot run git-rockstar!"
cat $CONFIGURE_OUTPUT
rm -f $CONFIGURE_OUTPUT
exit 1;
fi
source $DIR/.config
GIT_REPO=$1
GIT_ROCKSTAR_CONFIG=$2
if [ -z "$GIT_REPO" ]; then
echo "usage: $0 /path/to/my/git/repo [ /path/to/config/.git-rockstar ]"
exit 1;
fi
OUT=$DIR/.git_rockstar_output.$$
ERR=$DIR/.git_rockstar_error.$$
echo '' > $OUT
echo '' > $ERR
$PERL $DIR/collect_git_stats.pl $GIT_REPO $GIT_ROCKSTAR_CONFIG 2> $ERR > $OUT
STATUS=$?
if [ "$STATUS" -ne 0 ]; then
echo "Problems running collect_git_stats.pl!"
cat $ERR
exit 1;
fi
OUT2=$DIR/.git_rockstar_output2.$$
ERR2=$DIR/.git_rockstar_error2.$$
echo '' > $OUT2
echo '' > $ERR2
LABEL=""
SHORT_LABEL=""
GITHUB=$( cd $GIT_REPO; git config -l | /bin/grep github )
if [ -z "$GITHUB" ]; then
# Not on github
NAME=$( basename $GIT_REPO )
LABEL="Code Changes for Git Repo [ $NAME ]"
SHORT_LABEL=$NAME
else
NAME=$( echo $GITHUB | sed -e 's|^.*github.com[/:]||;' )
SHORT_NAME=$( echo $NAME | sed -e 's|\.git$||;' )
LABEL="Code Changes for Github [ $SHORT_NAME ]"
SHORT_LABEL=$SHORT_NAME
fi
echo $LABEL
SVG_NAME=$( echo $SHORT_LABEL | perl -pe 's|^.*/||; s|-|_|g; s|\s*$||; $_ .= "_rockstar.svg"' )
SVG_TMP=$GIT_REPO/$SVG_NAME
SVG=$( echo $SVG_TMP | perl -pe 's|//|/|g;' )
$RSCRIPT $DIR/create_graph.R $OUT "'$LABEL'" $SVG 2> $ERR2 > $OUT2
STATUS=$?
if [ "$STATUS" -ne 0 ]; then
echo "Problems running create_graph.R!"
cat $ERR2
exit 1;
fi
rm $OUT $OUT2 $ERR $ERR2
echo "Created SVG: $SVG"