Update to gitDemo.sh for utility functions

This commit is contained in:
Éibhear Ó hAnluain 2019-09-23 13:57:26 +01:00
parent b961847325
commit 20ba09bf0a
2 changed files with 122 additions and 124 deletions

View file

@ -1,25 +1,15 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR=$(cd $(dirname ${0}); pwd) SCRIPT_DIR=$(cd $(dirname ${0}); pwd)
BASEDIR=${SCRIPT_DIR}/devTeamDemo
declaim () { . ${SCRIPT_DIR}/utils.sh
echo
echo ${*} BASEDIR=${SCRIPT_DIR}/devTeamDemo
echo "==============="
echo
}
usage () { usage () {
declaim "${0} [-s]" declaim "${0} [-s]"
} }
sleepies () {
if [ "${SLEEPS}" = "Y" ]; then
sleep ${1}
fi
}
# We expect the group, project and branch as parameters # We expect the group, project and branch as parameters
export SLEEPS="N" export SLEEPS="N"
while getopts "sh" opt; do while getopts "sh" opt; do
@ -6010,53 +6000,53 @@ EOF
declaim "Cloning for the Master" declaim "Cloning for the Master"
# Clone # Clone
git clone ${BASEDIR}/javaBootcampNoEclipse.git ${BASEDIR}/javaBootcampNoEclipse.mastersClone git_command git clone ${BASEDIR}/javaBootcampNoEclipse.git ${BASEDIR}/javaBootcampNoEclipse.mastersClone
cd ${BASEDIR}/javaBootcampNoEclipse.mastersClone cd ${BASEDIR}/javaBootcampNoEclipse.mastersClone
# Set Master's config # Set Master's config
git config --local user.name "Master O'Theuniverse" git_command git config --local user.name "\"Master O'Theuniverse\""
git config --local user.email "master.otheuniverse@example.com" git_command git config --local user.email "master.otheuniverse@example.com"
# Master creates a release branch # Master creates a release branch
declaim "Master creates release branch" declaim "Master creates release branch"
git branch REL2018.11 master git_command git branch REL2018.11 master
git push origin REL2018.11 git_command git push origin REL2018.11
sleepies 15 sleepies 15
# Developer 1 clone # Developer 1 clone
declaim "Developer 1 clones" declaim "Developer 1 clones"
git clone ${BASEDIR}/javaBootcampNoEclipse.git ${BASEDIR}/javaBootcampNoEclipse.dev1 git_command git clone ${BASEDIR}/javaBootcampNoEclipse.git ${BASEDIR}/javaBootcampNoEclipse.dev1
cd ${BASEDIR}/javaBootcampNoEclipse.dev1 cd ${BASEDIR}/javaBootcampNoEclipse.dev1
# Set Developer 1's config # Set Developer 1's config
git config --local user.name "Developer O'Ne" git_command git config --local user.name "\"Developer O'Ne\""
git config --local user.email "developer.one@example.com" git_command git config --local user.email "developer.one@example.com"
# Developer 1 creates branch # Developer 1 creates branch
declaim "Developer 1 creates development branch from release branch" declaim "Developer 1 creates development branch from release branch"
git checkout REL2018.11 git_command git checkout REL2018.11
git branch REL2018.11_dev1 git_command git branch REL2018.11_dev1
git checkout REL2018.11_dev1 git_command git checkout REL2018.11_dev1
git push --set-upstream origin REL2018.11_dev1 git_command git push --set-upstream origin REL2018.11_dev1
sleepies 15 sleepies 15
# Developer 2 clone # Developer 2 clone
declaim "Developer 2 clones" declaim "Developer 2 clones"
git clone ${BASEDIR}/javaBootcampNoEclipse.git ${BASEDIR}/javaBootcampNoEclipse.dev2 git_command git clone ${BASEDIR}/javaBootcampNoEclipse.git ${BASEDIR}/javaBootcampNoEclipse.dev2
cd ${BASEDIR}/javaBootcampNoEclipse.dev2 cd ${BASEDIR}/javaBootcampNoEclipse.dev2
# Set Developer 2's config # Set Developer 2's config
git config --local user.name "Developer Two" git_command git config --local user.name "\"Developer Two\""
git config --local user.email "developer.two@example.com" git_command git config --local user.email "developer.two@example.com"
# Developer 2 creates branch # Developer 2 creates branch
declaim "Developer 2 creates development branch from release branch" declaim "Developer 2 creates development branch from release branch"
git checkout REL2018.11 git_command git checkout REL2018.11
git branch REL2018.11_dev2 git_command git branch REL2018.11_dev2
git checkout REL2018.11_dev2 git_command git checkout REL2018.11_dev2
git push --set-upstream origin REL2018.11_dev2 git_command git push --set-upstream origin REL2018.11_dev2
sleepies 15 sleepies 15
@ -6086,9 +6076,9 @@ index 516d50c..94aea57 100644
} }
EOF EOF
git add source git_command git add source
git commit -m "Moving this out to be a variable" git_command git commit -m "\"Moving this out to be a variable\""
git push git_command git push
sleepies 15 sleepies 15
@ -6114,21 +6104,21 @@ index b9f9725..0aad3a3 100644
</p> </p>
</body> </body>
EOF EOF
git add source git_command git add source
git commit -m "Formatting changes." git_command git commit -m "\"Formatting changes.\""
git push git_command git push
sleepies 15 sleepies 15
# Master creates a release branch # Master creates a release branch
declaim "Master creates another release branch" declaim "Master creates another release branch"
cd ${BASEDIR}/javaBootcampNoEclipse.mastersClone cd ${BASEDIR}/javaBootcampNoEclipse.mastersClone
git checkout REL2018.11 git_command git checkout REL2018.11
git pull --prune origin git_command git pull --prune origin
git checkout master git_command git checkout master
git pull --prune origin git_command git pull --prune origin
git branch REL2019.02 master git_command git branch REL2019.02 master
git push origin REL2019.02 git_command git push origin REL2019.02
sleepies 15 sleepies 15
@ -6136,11 +6126,11 @@ sleepies 15
declaim "Developer 1 develops for the second release branch" declaim "Developer 1 develops for the second release branch"
cd ${BASEDIR}/javaBootcampNoEclipse.dev1 cd ${BASEDIR}/javaBootcampNoEclipse.dev1
git fetch --prune git_command git fetch --prune
git checkout REL2019.02 git_command git checkout REL2019.02
git branch REL2019.02_dev1 git_command git branch REL2019.02_dev1
git checkout REL2019.02_dev1 git_command git checkout REL2019.02_dev1
git push --set-upstream origin REL2019.02_dev1 git_command git push --set-upstream origin REL2019.02_dev1
sleepies 15 sleepies 15
@ -6167,53 +6157,53 @@ index c55118d..6b88814 100644
out.println("<html>"); out.println("<html>");
out.println("<head>"); out.println("<head>");
EOF EOF
git add source git_command git add source
git commit -m "Further variablisation." git_command git commit -m "\"Further variablisation.\""
git push git_command git push
sleepies 15 sleepies 15
# Master prepares to merge development work to first release branch # Master prepares to merge development work to first release branch
declaim "Master prepares for merge requests" declaim "Master prepares for merge requests"
cd ${BASEDIR}/javaBootcampNoEclipse.mastersClone cd ${BASEDIR}/javaBootcampNoEclipse.mastersClone
git checkout master git_command git checkout master
git fetch --prune git_command git fetch --prune
for branch in $(git branch -l | grep -v master) for branch in $(git branch -l | grep -v master)
do do
git branch -D ${branch} git_command git branch -D ${branch}
done done
for branch in $(git branch -r | grep -v HEAD | sed 's/^\ \ origin\///') for branch in $(git branch -r | grep -v HEAD | sed 's/^\ \ origin\///')
do do
git branch ${branch} origin/${branch} git_command git branch ${branch} origin/${branch}
done done
git checkout master git_command git checkout master
# Master does the merge # Master does the merge
declaim "Master merges Developer 1 and Developer 2's work for first release" declaim "Master merges Developer 1 and Developer 2's work for first release"
git checkout REL2018.11 git_command git checkout REL2018.11
git merge --no-ff -m "Merge REL2018.11_dev1 following approved code-review" REL2018.11_dev1 git_command git merge --no-ff -m "\"Merge REL2018.11_dev1 following approved code-review\"" REL2018.11_dev1
git merge --no-ff -m "Merge REL2018.11_dev2 following approved code-review" REL2018.11_dev2 git_command git merge --no-ff -m "\"Merge REL2018.11_dev2 following approved code-review\"" REL2018.11_dev2
git push origin git_command git push origin
sleepies 15 sleepies 15
# Developer 1 merges the new merge into their own branch # Developer 1 merges the new merge into their own branch
declaim "Developer 1 updates their working area following the merge" declaim "Developer 1 updates their working area following the merge"
cd ${BASEDIR}/javaBootcampNoEclipse.dev1 cd ${BASEDIR}/javaBootcampNoEclipse.dev1
git fetch --prune git_command git fetch --prune
git checkout REL2018.11_dev1 git_command git checkout REL2018.11_dev1
git pull origin REL2018.11 git_command git pull origin REL2018.11
git push origin git_command git push origin
sleepies 15 sleepies 15
# Developer 2 merges the new merge into their own branch # Developer 2 merges the new merge into their own branch
declaim "Developer 2 updates their working area following the merge" declaim "Developer 2 updates their working area following the merge"
cd ${BASEDIR}/javaBootcampNoEclipse.dev2 cd ${BASEDIR}/javaBootcampNoEclipse.dev2
git fetch --prune git_command git fetch --prune
git checkout REL2018.11_dev2 git_command git checkout REL2018.11_dev2
git pull origin REL2018.11 git_command git pull origin REL2018.11
git push origin git_command git push origin
sleepies 15 sleepies 15
@ -6221,8 +6211,8 @@ sleepies 15
declaim "Developer 1 makes an update for the first release" declaim "Developer 1 makes an update for the first release"
cd ${BASEDIR}/javaBootcampNoEclipse.dev1 cd ${BASEDIR}/javaBootcampNoEclipse.dev1
git fetch --prune git_command git fetch --prune
git checkout REL2018.11_dev1 git_command git checkout REL2018.11_dev1
cat -v <<EOF | patch -p1 cat -v <<EOF | patch -p1
diff --git a/source/java/org/gibiris/javaBootcampNoEclipse/MyHelloWorldBean.java b/source/java/org/gibiris/javaBootcampNoEclipse/MyHelloWorldBean.java diff --git a/source/java/org/gibiris/javaBootcampNoEclipse/MyHelloWorldBean.java b/source/java/org/gibiris/javaBootcampNoEclipse/MyHelloWorldBean.java
@ -6238,65 +6228,65 @@ index 94aea57..dd5fb5d 100644
String strMyMessage; String strMyMessage;
EOF EOF
git add source git_command git add source
git commit -m "Noting that this is needed for the REL2019.02 release." git_command git commit -m "\"Noting that this is needed for the REL2019.02 release.\""
git push origin git_command git push origin
sleepies 15 sleepies 15
# Master prepares to merge development work to first release branch # Master prepares to merge development work to first release branch
declaim "Master merges Developer 1's new update to the first release" declaim "Master merges Developer 1's new update to the first release"
cd ${BASEDIR}/javaBootcampNoEclipse.mastersClone cd ${BASEDIR}/javaBootcampNoEclipse.mastersClone
git checkout master git_command git checkout master
git fetch --prune git_command git fetch --prune
for branch in $(git branch -l | grep -v master) for branch in $(git branch -l | grep -v master)
do do
git branch -D ${branch} git_command git branch -D ${branch}
done done
for branch in $(git branch -r | grep -v HEAD | sed 's/^\ \ origin\///') for branch in $(git branch -r | grep -v HEAD | sed 's/^\ \ origin\///')
do do
git branch ${branch} origin/${branch} git_command git branch ${branch} origin/${branch}
done done
git checkout master git_command git checkout master
# Master does the merge # Master does the merge
git checkout REL2018.11 git_command git checkout REL2018.11
git merge --no-ff -m "Merge of latter work on REL2018.11_dev1 following approved code-review" REL2018.11_dev1 git_command git merge --no-ff -m "\"Merge of latter work on REL2018.11_dev1 following approved code-review\"" REL2018.11_dev1
git push origin git_command git push origin
sleepies 15 sleepies 15
# Master does the follow-on merge # Master does the follow-on merge
declaim "Master propagates the work for the first release on to the branch for the second release" declaim "Master propagates the work for the first release on to the branch for the second release"
git checkout REL2019.02 git_command git checkout REL2019.02
git merge --no-ff -m "Merge of work on REL2018.11 to here as it's needed" REL2018.11 git_command git merge --no-ff -m "\"Merge of work on REL2018.11 to here as it's needed\"" REL2018.11
git push origin git_command git push origin
sleepies 15 sleepies 15
# REL2018.11 goes live. Merge to master # REL2018.11 goes live. Merge to master
declaim "Master merges the work on the first release to master" declaim "Master merges the work on the first release to master"
git checkout master git_command git checkout master
git fetch --prune git_command git fetch --prune
for branch in $(git branch -l | grep -v master) for branch in $(git branch -l | grep -v master)
do do
git branch -D ${branch} git_command git branch -D ${branch}
done done
for branch in $(git branch -r | grep -v HEAD | sed 's/^\ \ origin\///') for branch in $(git branch -r | grep -v HEAD | sed 's/^\ \ origin\///')
do do
git branch ${branch} origin/${branch} git_command git branch ${branch} origin/${branch}
done done
git checkout master git_command git checkout master
git tag REL2018.11.0 REL2018.11 git_command git tag REL2018.11.0 REL2018.11
git merge --no-ff -m "REL2018.11 now live" REL2018.11 git_command git merge --no-ff -m "\"REL2018.11 now live\"" REL2018.11
git push origin git_command git push origin
sleepies 15 sleepies 15
# Master tags and removes REL2018.11 # Master tags and removes REL2018.11
git push origin :REL2018.11 git_command git push origin :REL2018.11
git push --tags origin git_command git push --tags origin
sleepies 15 sleepies 15
@ -6305,22 +6295,22 @@ declaim "Developers update their working areas"
for dev in dev1 dev2 for dev in dev1 dev2
do do
cd ${BASEDIR}/javaBootcampNoEclipse.${dev} cd ${BASEDIR}/javaBootcampNoEclipse.${dev}
git checkout master git_command git checkout master
git fetch --prune git_command git fetch --prune
for branch in $(git branch -l | grep -v master) for branch in $(git branch -l | grep -v master)
do do
git branch -D ${branch} git_command git branch -D ${branch}
done done
git push origin :REL2018.11_${dev} git_command git push origin :REL2018.11_${dev}
sleepies 15 sleepies 15
for branch in $(git branch -r | grep -v HEAD | sed 's/^\ \ origin\///') for branch in $(git branch -r | grep -v HEAD | sed 's/^\ \ origin\///')
do do
git branch ${branch} origin/${branch} git_command git branch ${branch} origin/${branch}
done done
git checkout master git_command git checkout master
git merge origin/master git_command git merge origin/master
done done
sleepies 15 sleepies 15
@ -6328,56 +6318,56 @@ sleepies 15
# Developer 1 merges updates to the second release branch into their own development branch # Developer 1 merges updates to the second release branch into their own development branch
declaim "Developer 1 updates their 2nd release branch working area following the cross-merge" declaim "Developer 1 updates their 2nd release branch working area following the cross-merge"
cd ${BASEDIR}/javaBootcampNoEclipse.dev1 cd ${BASEDIR}/javaBootcampNoEclipse.dev1
git fetch --prune git_command git fetch --prune
git checkout REL2019.02_dev1 git_command git checkout REL2019.02_dev1
git merge -m "Updating my dev branch with the 2018.11 release" origin/REL2019.02 git_command git merge -m "\"Updating my dev branch with the 2018.11 release\"" origin/REL2019.02
git push origin git_command git push origin
sleepies 15 sleepies 15
# Master prepares to merge development work to second release branch # Master prepares to merge development work to second release branch
declaim "Master prepares for merge requests" declaim "Master prepares for merge requests"
cd ${BASEDIR}/javaBootcampNoEclipse.mastersClone cd ${BASEDIR}/javaBootcampNoEclipse.mastersClone
git checkout master git_command git checkout master
git fetch --prune git_command git fetch --prune
for branch in $(git branch -l | grep -v master) for branch in $(git branch -l | grep -v master)
do do
git branch -D ${branch} git_command git branch -D ${branch}
done done
for branch in $(git branch -r | grep -v HEAD | sed 's/^\ \ origin\///') for branch in $(git branch -r | grep -v HEAD | sed 's/^\ \ origin\///')
do do
git branch ${branch} origin/${branch} git_command git branch ${branch} origin/${branch}
done done
git checkout master git_command git checkout master
# Master does the merge # Master does the merge
declaim "Master merges Developer 1's work for second release" declaim "Master merges Developer 1's work for second release"
git checkout REL2019.02 git_command git checkout REL2019.02
git merge --no-ff -m "Merge REL2019.02_dev1 following approved code-review" REL2019.02_dev1 git_command git merge --no-ff -m "\"Merge REL2019.02_dev1 following approved code-review\"" REL2019.02_dev1
git push origin git_command git push origin
sleepies 15 sleepies 15
# REL2019.02 goes live. Merge to master # REL2019.02 goes live. Merge to master
declaim "Master merges the work on the second release to master" declaim "Master merges the work on the second release to master"
git checkout master git_command git checkout master
git fetch --prune git_command git fetch --prune
for branch in $(git branch -l | grep -v master) for branch in $(git branch -l | grep -v master)
do do
git branch -D ${branch} git_command git branch -D ${branch}
done done
for branch in $(git branch -r | grep -v HEAD | sed 's/^\ \ origin\///') for branch in $(git branch -r | grep -v HEAD | sed 's/^\ \ origin\///')
do do
git branch ${branch} origin/${branch} git_command git branch ${branch} origin/${branch}
done done
git checkout master git_command git checkout master
git tag REL2019.02.0 REL2019.02 git_command git tag REL2019.02.0 REL2019.02
git merge --no-ff -m "REL2019.02 now live" REL2019.02 git_command git merge --no-ff -m "\"REL2019.02 now live\"" REL2019.02
git push origin git_command git push origin
sleepies 15 sleepies 15
# Master tags and removes REL2019.02 # Master tags and removes REL2019.02
git push origin :REL2019.02 git_command git push origin :REL2019.02
git push --tags origin git_command git push --tags origin

View file

@ -7,6 +7,14 @@ declaim () {
echo echo
} }
# A function to sleep for a bit if the environmental variable SLEEPS
# is Y
sleepies () {
if [ "${SLEEPS}" = "Y" ]; then
sleep ${1}
fi
}
# A function to print the git command to be executed and then to # A function to print the git command to be executed and then to
# execute it # execute it
git_command() { git_command() {