blob: 174532b62d338b8e4b032e79c6d9b1ab818c1e46 [file] [log] [blame]
#!/usr/bin/env bash
# Utility script to semi-automate creation of a branch using committer shell (or, e4Build id)
#project=simrel
project=simrel
#project=jdt
#reponame=eclipse.platform.team
#reponame=eclipse.jdt.debug
#reponame=eclipse.platform.releng
reponame=org.eclipse.simrel.build
startTag=v20140805-2300
#startTag=JunoSR0
#startTag=R4_2
#startTag=R3_8
branchName=Luna_maintenance
#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/simrel/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"
# TODO: something was going wrong here, last time I tried to use.
# not sure if "silly mistake", or ... what. Perhaps I had startTag wrong,
# BUT, should compare with with "makeBranch" scripts?
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