forked from adoptium/mirror-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
freebsdRepoSync.sh
executable file
·97 lines (74 loc) · 1.91 KB
/
freebsdRepoSync.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env bash
# Script to facilitate automatic merging of changes from the AdoptOpenJDK
# repos into child repos
# The reference AdoptOpenJDK repos
export ADOPT_REPO_PATH=git@github.com:AdoptOpenJDK
# This script could be made to sync any child by passing this in as an arg
export CHILD_REPO_PATH=git@github.com:freebsd
# Branch to be synchronised
# Note: the dev branch is the branch that AdoptOpenJDK builds from
export SYNC_BRANCH=dev
# How to use this script
usage() {
echo "Usage: sync <version>" 1>&2
echo "Where <version> is a valid Java version, e.g. 8, 11" 1>&2
}
# Initialise the repo to be sync'ed
initRepo() {
if [ -d ${REPO} ]; then
cd ${REPO}
# Some local changes may prevent a pull from succeeding
# To avoid that, reset the repo here
git reset --hard origin/${SYNC_BRANCH} || exit 1
git pull || exit 1
else
git clone ${CHILD_REPO_PATH}/${REPO}.git || exit 1
cd ${REPO}
git checkout ${SYNC_BRANCH} || exit 1
fi
}
# Verify that we have a parent
verifyParent() {
if ! git config remote.upstream.url > /dev/null; then
git remote add upstream ${ADOPT_REPO_PATH}/${REPO}.git || exit 1
fi
if [ "x$(git config remote.upstream.url)" != "x${ADOPT_REPO_PATH}/${REPO}.git" ]; then
echo "WARNING: 'upstream' doesn't point to AdoptOpenJDK parent" 1>&2
fi
}
# Fetch all parent changes, including tags
fetchParent() {
git fetch --all || exit 1
git fetch upstream --tags || exit 1
}
# Merge in changes from the parent
mergeRepo() {
git merge -m "Merge from Adoptium ${SYNC_BRANCH}" upstream/${SYNC_BRANCH} || exit 1
}
# Push
pushMerge() {
git push || exit 1
git push --tags || exit 1
}
export REPO=
case $1 in
8|9|1[0-9])
export REPO=openjdk-jdk${1}u
;;
*)
usage
exit 1
esac
echo "Common defs"
. import-common.sh
checkGitVersion
echo "Initialising repo"
initRepo
echo "Verifying parent"
verifyParent
echo "Fetching parent"
fetchParent
echo "Merge changes"
mergeRepo
echo "Push"
pushMerge