-
Notifications
You must be signed in to change notification settings - Fork 5
/
git-cvsimport.sh
executable file
·78 lines (63 loc) · 1.58 KB
/
git-cvsimport.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
71
72
73
74
75
76
77
78
#!/bin/sh
# config
# source for import:
# "url": a tarball snapshot
#url=ftp://ftp.astron.com/pri/file-nightly.tar.gz
# "rsync" use rsync
# for rsync, you need to setup ~/.ssh/config:
#Host file
# Hostname address.from.where.to.sync
# ForwardAgent no
# User glen
rsync=file:file
# git url where to push
[email protected]:file/file.git
# code
set -e
dir=$(dirname "$0")
cd "$dir"
# precaution not to run it accidentally as root
if [ $(stat -c %u .) != $(id -u) ]; then
echo >&2 "You (`id -un`) not owner (`stat -c %U .`) of this dir (`pwd`), aborting"
exit 1
fi
# load ssh key
if [ -f /usr/share/okas/ssh-auth-sock ]; then
. /usr/share/okas/ssh-auth-sock
ssh-auth-sock
fi
if [ -n "$rsync" ]; then
rsync -axSH -e ssh "$rsync/" cvs/file/
else
if [ "$1" = "update" ]; then
rm -f file-nightly.tar.gz
fi
if [ ! -f file-nightly.tar.gz ]; then
wget -q $url -O .tmp.$$.tgz
if [ -d cvs/file ]; then
mv cvs/file .tmp.$$.file
rm -rf .tmp.$$.file &
fi
mv -f .tmp.$$.tgz file-nightly.tar.gz
fi
if [ ! -d cvs/file ]; then
install -d cvs/CVSROOT
cd cvs
tar -xzf ../file-nightly.tar.gz
cd ..
fi
fi
out=$(git -c i18n.commitencoding=iso8859-1 cvsimport -d $(pwd)/cvs -R -A file.users -C git file 2>&1)
# filter out common noise. must be separate subshell to catch errors from git command
out=$(echo "$out" | sed -e '/Skipping #CVSPS_NO_BRANCH/d')
if [ "$out" = "Already up-to-date." ]; then
exit 0
fi
echo "$out"
cd git
if ! git config remote.origin.url >/dev/null; then
git remote add origin $push_url
git push --mirror
fi
git push origin refs/heads/master refs/tags/*
cd ..