-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathgit-svn-cloneback.sh
59 lines (51 loc) · 1.17 KB
/
git-svn-cloneback.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
#!/bin/bash
display_usage() {
echo "Perform a git svn clone based on the last <limit> revisions of the SVN repo."
echo " Usage:"
echo ""
echo " $0 -u <SVN url> -l <limit>"
echo ""
echo " # Example: Clone just the last 500 revisions from the SVN HEAD"
echo ""
echo " $0 -u https://svn/proj/trunk -l 500"
echo ""
echo " # Example: Clone starting from 4 revisions before SVN r9871"
echo ""
echo " $0 -u https://svn/proj/trunk@9871 -l 4"
echo ""
echo " # Example: Clone last 20 revisions into mydir"
echo ""
echo " $0 -u https://svn/proj/trunk -l 20 -o mydir --authors-file=svn-auth.txt"
}
if [ $# -le 1 ]
then
display_usage
exit 1
fi
while [[ $# > 0 ]]
do
key="$1"
case $key in
-l|--limit)
REV_COUNT="$2"
shift
;;
-u|--url)
SVN_URL="$2"
shift
;;
-o|--output)
OUTPUT="$2"
shift
;;
*)
REMAINING="${REMAINING} ${1}"
;;
esac
shift
done
MYDIR="$(dirname "$(realpath "$0")")"
FIRST_REV=$( source ${MYDIR}/svn-lookback.sh -u ${SVN_URL} -l ${REV_COUNT} )
echo "Executing: "
echo " git svn clone ${REMAINING} -r${FIRST_REV}:HEAD ${SVN_URL} ${OUTPUT}"
git svn clone ${REMAINING} -r${FIRST_REV}:HEAD ${SVN_URL} ${OUTPUT}