-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathauto-update-git-branches
executable file
·44 lines (39 loc) · 1.2 KB
/
auto-update-git-branches
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
#!/bin/sh -ex
# Updates a branch by doing the following:
# - switch to the target branch
# - Merge the source branch but keep anything on the development branch
# in case of conflicts.
# - Update the target branch.
function updateBranch()
{
SOURCE_BRANCH=$1
TARGET_BRANCH=$2
git clean -fdx
git reset --hard origin/$TARGET_BRANCH
git clean -fdx
git merge --no-ff -X ours origin/$SOURCE_BRANCH
git commit --amend -m "Merge $SOURCE_BRANCH into $TARGET_BRANCH."
if [ "X`git diff --name-only HEAD origin/$TARGET_BRANCH | tail -1`" != "X" ]; then
git push origin HEAD:$TARGET_BRANCH
fi
}
# Clone once
cd $WORKSPACE
rm -rf alidist
if [ ! -d alidist ]; then
git clone git@github.com:alisw/alidist
fi
cd alidist
# Make sure we push with our correct name and address in the case our user does
# not have an home directory, e.g. under mesos.
if [ X$HOME = X ]; then
git config user.email "alice.builder@cern.ch"
git config user.name "ALICE Builder"
fi
git fetch origin
ERROR=0
updateBranch IB/v5-08/next IB/master/root6 || ERROR=1
updateBranch IB/master/root6 IB/v5-08/o2 || ERROR=1
updateBranch IB/v5-06/prod IB/v5-06/next || ERROR=1
updateBranch IB/v5-08/prod IB/v5-08/next || ERROR=1
exit $ERROR