Making it a little more explicit what the commands being executed are.

This commit is contained in:
Éibhear Ó hAnluain 2019-09-23 13:13:37 +01:00
parent 325a3cce55
commit 42c34cc1c1

View file

@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
# A function to make a statement.
declaim () { declaim () {
echo echo
echo ${*} echo ${*}
@ -7,6 +8,35 @@ declaim () {
echo echo
} }
# A function to print the git command to be executed and then to
# execute it
git_command() {
# Print out the command.
echo
echo "git command: ${*}"
# Some variable initialisations
COMMANDSTRING="${*}"
counter=0
UNDERLINESTRING=""
# Build UNDERLINESTRING to be a string of '-' characters the same
# length of all the options passed in.
while [ ${counter} -lt ${#COMMANDSTRING} ]
do
UNDERLINESTRING="${UNDERLINESTRING}-"
counter=$(( ${counter} + 1 ))
done
# Print the pretty underline
echo -n " "
echo ${UNDERLINESTRING}
echo
# Execute the command.
eval ${*}
}
SCRIPT_DIR=$(cd $(dirname ${0}); pwd) SCRIPT_DIR=$(cd $(dirname ${0}); pwd)
REPO_DIR=${SCRIPT_DIR}/simpleRepo REPO_DIR=${SCRIPT_DIR}/simpleRepo
@ -23,10 +53,11 @@ mkdir -vp ${REPO_DIR}
cd ${REPO_DIR} cd ${REPO_DIR}
declaim "Initialising it as a git repository" declaim "Initialising it as a git repository"
git init . git_command git init ${REPO_DIR}
git config --local user.name "Gaius Julius Caesar" declaim "Setting user.name and user.email for this local repository"
git config --local user.email "gjcaesar@pontifexmaximus.rm" git_command git config --local user.name "\"Gaius Julius Caesar\""
git_command git config --local user.email gjcaesar@pontifexmaximus.rm
declaim "Creating a text file" declaim "Creating a text file"
cat <<EOF > information.md cat <<EOF > information.md
@ -38,27 +69,27 @@ This is a file for demonstration purposes
EOF EOF
declaim "Adding and commiting that text file. The first commit" declaim "Adding and commiting that text file. The first commit"
git add information.md git_command git add information.md
git commit -m "commit1" git_command git commit -m "\"commit1\""
declaim "Updating the text file" declaim "Updating the text file"
echo "This is a second line of information." >> information.md echo "This is a second line of information." >> information.md
echo >> information.md echo >> information.md
declaim "Adding and commiting that text file. The second commit" declaim "Adding and commiting that text file. The second commit"
git add information.md git_command git add information.md
git commit -m "commit2" git_command git commit -m "\"commit2\""
declaim "Updating the text file for the second time" declaim "Updating the text file for the second time"
echo "This is a third line of information." >> information.md echo "This is a third line of information." >> information.md
echo >> information.md echo >> information.md
declaim "Adding and commiting that text file. The third commit" declaim "Adding and commiting that text file. The third commit"
git add information.md git_command git add information.md
git commit -m "commit3" git_command git commit -m "\"commit3\""
declaim "Creating and checking out the Rel1 branch" declaim "Creating and checking out the Rel1 branch"
git checkout -b Rel1 git_command git checkout -b Rel1
declaim "Updating the text file on the Rel1 branch" declaim "Updating the text file on the Rel1 branch"
cat <<EOF >> information.md cat <<EOF >> information.md
@ -70,8 +101,8 @@ This is more information added as part of Rel1
EOF EOF
declaim "Adding and commiting that text file. The fourth commit" declaim "Adding and commiting that text file. The fourth commit"
git add information.md git_command git add information.md
git commit -m "commit4" git_command git commit -m "\"commit4\""
declaim "Updating the text file on the Rel1 branch again" declaim "Updating the text file on the Rel1 branch again"
mv -v information.md{,.hold} mv -v information.md{,.hold}
@ -79,12 +110,12 @@ cat information.md.hold | sed 's/of Rel1$/of Rel1./' > information.md
rm information.md.hold rm information.md.hold
declaim "Adding and commiting that text file. The fifth commit" declaim "Adding and commiting that text file. The fifth commit"
git add information.md git_command git add information.md
git commit -m "commit5" git_command git commit -m "\"commit5\""
declaim "Creating and checking out the Rel2 branch" declaim "Creating and checking out the Rel2 branch"
git checkout master git_command git checkout master
git checkout -b Rel2 git_command git checkout -b Rel2
declaim "Updating the text file on the Rel2 branch" declaim "Updating the text file on the Rel2 branch"
mv information.md{,.hold} mv information.md{,.hold}
@ -99,8 +130,8 @@ cat information.md.hold >> information.md
rm information.md.hold rm information.md.hold
declaim "Adding and commiting that text file. The sixth commit" declaim "Adding and commiting that text file. The sixth commit"
git add information.md git_command git add information.md
git commit -m "commit6" git_command git commit -m "\"commit6\""
declaim "Updating the text file on the Rel2 branch again" declaim "Updating the text file on the Rel2 branch again"
mv information.md{,.hold} mv information.md{,.hold}
@ -108,10 +139,10 @@ cat information.md.hold | sed 's/of Rel2$/of Rel2./' > information.md
rm information.md.hold rm information.md.hold
declaim "Adding and commiting that text file. The seventh commit" declaim "Adding and commiting that text file. The seventh commit"
git add information.md git_command git add information.md
git commit -m "commit7" git_command git commit -m "\"commit7\""
declaim "Checking out master" declaim "Checking out master"
git checkout master git_command git checkout master
git log --oneline --graph --decorate --all git_command git log --oneline --graph --decorate --all