forked from r-devel/r-svn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvn-sync.sh
executable file
·41 lines (40 loc) · 1.23 KB
/
svn-sync.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
#!/usr/bin/env bash
#
#
# Git/SVN setup:
# git svn clone -T trunk https://svn.r-project.org/R
# git checkout origin/trunk -b trunk
# git remote add github https://github.com/r-devel/r-svn
# git checkout master
# git fetch github master
# git reset --hard github/master
set -e
set -x
git checkout trunk
git svn rebase
git push github trunk
git checkout master
git fetch github master
git reset --hard github/master
LASTMSG=$(git log master --grep="git-svn-id: https://svn.r-project.org/R/trunk" -n1 | grep -o 'git-svn-id: [^ ]*')
LASTSVN=$(git log trunk --grep="$LASTMSG" -n1 --pretty="%H")
if [ -z "$LASTSVN" ]; then
echo "FAILED TO FIND LASTSVN"
exit 1
fi
COMMIT_ARRAY=($(git log $LASTSVN...trunk --reverse --pretty='%H'))
if [ -z "$COMMIT_ARRAY" ]; then
echo "No new commits found!"
exit 0
fi
for hash in "${COMMIT_ARRAY[@]}"
do
GIT_COMMITTER_DATE="$(git log -1 $hash --pretty=format:%cd)" \
GIT_COMMITTER_NAME="$(git log -1 $hash --pretty=format:%cn)" \
GIT_COMMITTER_EMAIL="$(git log -1 $hash --pretty=format:%ce)" \
git cherry-pick "$hash"
git push github master
done
# Check that master and trunk are identical except for .github directory
# This verifies that we haven't omitted any commits
git diff --stat master trunk -- . ':(exclude).github'