-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitsvntrackrelease
executable file
·73 lines (66 loc) · 2.31 KB
/
gitsvntrackrelease
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
70
71
72
73
#!/bin/bash
#
# *********************************************************************** #
# author: fmarcos83 #
# email : [email protected] #
# A system to track svn branches after the repo was fetched #
# inspired completely by this article #
# *********************************************************************** #
# http://stackoverflow.com/questions/296975/how-do-i-tell-git-svn-about-a-remote-branch-created-after-i-fetched-the-repo
#extracting the svn repository
#TODO: check for errors if we are not inside a git svn repo
requires="
This script only can work under a git svn repository
"
result=$(git svn info > /dev/null 3>&1 2>&1 );
if [[ 0 -lt $? ]]; then
echo -e $requires;
exit 1;
fi
svnRoot=$(git svn info | grep 'Root' | sed 's/Repository Root:\s*//g');
helpMessage="
Tool to trak remote releases with git svn\n
-b sets the name of the new svn remote release to track\n
-l sets the name of the new local release we want to sync with\n
"
OPTIND=1
options='b:l'
while getopts $options OPTION;
do
case $OPTION in
# gets the name of the branch we want to track
b)
#branch is the name of the new remote branch you want to sync to
branch="$OPTARG"
;;
# gets the name of the local branch we want to create
l)
#local branch is the name of the new local branch you want to create
localbranch="$OPTARG"
;;
t)
type="$OPTARG"
;;
?)
echo -e $helpMessage
;;
esac
done
#branches path is assuming a default layout
newBranchRemotePath="$svnRoot/releases/$branch"
if [[ -z $branch ]]; then
echo 'b) can not be empty'
exit 1;
fi
if [[ -z $localbranch ]]; then
localbranch="local/$branch"
fi
#TODO set sanity checks to check if we want to override some configuration
#or warn the user that the current configuration already exists
#adding a remote
$(git config --add svn-remote.$branch.url $newBranchRemotePath)
#telling git where to fetch the changes
$(git config --add svn-remote.$branch.fetch :refs/remotes/$branch)
#fetching the new changes
$(git svn fetch "$branch")
$(git checkout -b $localbranch -t $branch)