forked from chhitz/scribus_svn_git
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgit_repo_init.sh
executable file
·70 lines (59 loc) · 1.52 KB
/
git_repo_init.sh
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
#!/bin/bash
SVN_SERVER=svn://scribus.net
# check whether whiptail or dialog is installed
read dialog <<< "$(which whiptail dialog 2> /dev/null)"
# exit if none found
[[ "$dialog" ]] || {
echo 'neither whiptail nor dialog found' >&2
exit 1
}
function show_list {
title=$1
shift
checklist=""
n=1
for branch in $@
do
checklist="$checklist ${branch%/} $n"
git config --get svn-remote.svn.fetch "(branches|tags)/${branch%/}" 2> /dev/null
if [ $? -eq 0 ]
then
checklist="$checklist on"
else
checklist="$checklist off"
fi
n=$[n+1]
done
exec 3>&1
choices=$($dialog --checklist "$title" 0 0 0 $checklist 2>&1 1>&3)
exitcode=$?
exec 3>&-
}
svn_branches=$(svn ls $SVN_SERVER/branches 2> /dev/null)
show_list "Select branches to import" $svn_branches
branch_choices=$choices
if [ $exitcode -ne 0 ]
then
exit 1
fi
svn_tags=$(svn ls $SVN_SERVER/tags 2> /dev/null)
show_list "Select tags to import" $svn_tags
tag_choices=$choices
if [ $exitcode -ne 0 ]
then
exit 1
fi
#create backup of .git/config
cp .git/config .git/config.bak
git config svn.authorsfile $(dirname $0)/svn_authors.txt
git config svn-remote.svn.url $SVN_SERVER
git config --unset-all svn-remote.svn.fetch
git config svn-remote.svn.fetch trunk/Scribus:refs/heads/master
for choice in $branch_choices
do
git config --add svn-remote.svn.fetch "branches/$choice/Scribus:refs/heads/$choice"
done
for choice in $tag_choices
do
git config --add svn-remote.svn.fetch "tags/$choice/Scribus:refs/remotes/svn/tags/$choice"
done