-
Notifications
You must be signed in to change notification settings - Fork 3
/
sync_repo.sh
executable file
·43 lines (32 loc) · 1.16 KB
/
sync_repo.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
#!/usr/bin/env bash
# Configuration
SOURCE_REPO=https://github.com/apache/flink.git
TARGET_REPO=https://github.com/flink-ci/flink-mirror.git
TARGET_BRANCHES="master"
echo "Syncing branches"
# update last sync file
date > .last-sync
if [ ! -d ".repo" ]; then
echo "SOURCE_REPO ($SOURCE_REPO) does not exist. Cloning ..."
git clone --mirror $SOURCE_REPO .repo
cd .repo
else
# update list of current branches
cd .repo
git fetch origin 'refs/heads/release-*:refs/release-*'
fi
# echo "Fetching from SOURCE_REPO ($SOURCE_REPO)"
# git fetch origin master
# the 3 most-recent release branches need to be covered when a new release branch is cut but the release is not finalized, yet
for RELEASE_BRANCH in `git branch -a | grep "release-" | grep -v "rc" | sort -V -r | head -n 3` ; do
TARGET_BRANCHES+=" $RELEASE_BRANCH"
done
echo "Fetching branches '$TARGET_BRANCHES' from SOURCE_REPO ($SOURCE_REPO)"
git fetch origin $TARGET_BRANCHES
echo "Pushing branches '$TARGET_BRANCHES' to TARGET_REPO ($TARGET_REPO)"
# generating refspec
REFSPEC=""
for TARGET_BRANCH in $TARGET_BRANCHES ; do
REFSPEC+="$TARGET_BRANCH:$TARGET_BRANCH "
done
git push $TARGET_REPO $REFSPEC