Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 842bd438913ec2ff2bcb86e4a3f11a92e04ccd1a (plain) (blame)
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
#!/usr/bin/env bash

# Utility script to semi-automate creation of a branch using committer shell (or, e4Build id)

#project=simrel
project=platform
#project=jdt

#reponame=eclipse.platform.team
#reponame=eclipse.jdt.debug
#reponame=eclipse.platform.releng
#reponame=org.eclipse.simrel.build
reponame=eclipse.platform.releng.maps

startTag=R4_2_2
#startTag=JunoSR0
#startTag=R4_2
#startTag=R3_8
branchName=R4_2_2_maintenance_patches
#branchName=R4_2_maintenance
#branchName=R3_8_maintenance

source checkForErrorExit.sh

repoprojectroot=/gitroot/$project
gitreponame=$reponame.git
repo=${repoprojectroot}/${gitreponame}

printf "\n\t%s" "Creating branch $branchName from $startTag "
printf "\n\t%s\n\n" "   for repo $repo "

temprepoarea=/shared/eclipse/temp/mkbranch
mkdir -p $temprepoarea
checkForErrorExit $? "Could not create temprepoarea!?: $temprepoarea"
cd $temprepoarea
checkForErrorExit $? "Could not cd to temprepoarea!?: $temprepoarea"

git clone $repo
checkForErrorExit $? "Could not create clone repo: $repo"


cd $reponame
checkForErrorExit $? "Could not cd to reponame: $reponame"

git checkout master
checkForErrorExit $? "Error during initial checkout of master"

git fetch
checkForErrorExit $? "Error during fetch"

git checkout -b $branchName $startTag
checkForErrorExit $? "Could not create local branch ($branchName) from tag ($startTag)"

# The part above could be done by anyone. The following code is where committer access is required
# (which is accomplished by using e4Build id for the general case).

# note: using cd here is where executing this whole thing from a committer shell on server is handy
cd $repo
checkForErrorExit $? "Could not cd to repo: $repo"

git config hooks.allowcreatenottopicbranch true
checkForErrorExit $? "Could not change config hook"

cd -
checkForErrorExit $? "Could not cd back to local repo"

git push origin $branchName
checkForErrorExit $? "Could not push branch to origin"

cd $repo
checkForErrorExit $? "Could not cd to repo: $repo"

git config --unset hooks.allowcreatenottopicbranch
checkForErrorExit $? "Could not unset config hook"

# simple cleanup ...
#rm -fr $temprepoarea
#checkForErrorExit $? "Error while removing temp repo"

printf "\n\t%s" "Completed creating branch $branchName from $startTag "
printf "\n\t%s\n\n" "   for repo $repo "

exit 0

Back to the top