5.3. Creating the training repositories

The training repositories are set up just one, and then copied by students.

5.3.1. Creating the small training repository

To create the training/workflow.small repository (for command line training), use the script (./make_training_repo_small.sh):

#!/bin/bash -ev

# create new repository
work_dir=/scratch/training.small.setup/
rm -rf ${work_dir}
mkdir ${work_dir}
cd  ${work_dir}

git init
git config user.name "Diamond Light Source"
git config user.email "gda@diamond.ac.uk"
git remote add origin dascgitolite@dasc-git.diamond.ac.uk:training/template/workflow.small.git

# populate the master branch and commit
cat <<END_OF_FILE > .project
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>workflow.small</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
    </buildSpec>
    <natures>
    </natures>
</projectDescription>
END_OF_FILE

cat <<END_OF_FILE > buckminster.cspec
<?xml version="1.0" encoding="UTF-8"?>
<cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0" name="workflow.small" componentType="buckminster" version="1.0.0"/>
END_OF_FILE

echo "Let's call this version trunk" > version.txt              # create new file
git add -A
git commit -m "Initial \"trunk\" commit"                        # commit to local repository

# create a new 8.14 branch and commit
git checkout -b 8.14
sed --in-place 's/trunk/8.14/' version.txt                      # modify existing file
git add -A
git commit -m "Make 8.14 branch"                                # commit to local repository

# make a change on the 8.14 branch
git checkout 8.14
echo "A file added to 8.14" > added-to-8.14.txt                 # create new file
git add -A
git commit -m "Add new file in 8.14"                            # commit to local repository

# make a change on trunk
git checkout master
echo "Added post-8.14 file" > added-to-trunk-after-8.14.txt     # create new file
git add -A
git commit -m "Add new file after 8.14"                         # commit to local repository

# create a new 8.16 branch and commit
git checkout -b 8.16
sed --in-place 's/trunk/8.16/' version.txt                      # modify existing file
git add -A
git commit -m "Make 8.16 branch"                                # commit to local repository

# make a change on the 8.16 branch
git checkout 8.16
echo "A file added to 8.16" > added-to-8.16.txt                 # create new file
git add -A
git commit -m "Add new file in 8.16"                            # commit to local repository

# make a change on trunk
git checkout master
echo "Added post-8.16 file" > added-to-trunk-after-8.16.txt     # create new file
git add -A
git commit -m "Add new file after 8.16"                         # commit to local repository

# push all branches to remote repository, overwriting existing contents
git push --mirror --verbose

5.3.2. Creating the large training repositories

To create the training/workflow.master, training/workflow.a, training/workflow.b repositories (for IDE training), use the script (./make_training_repo_large.sh):

#!/bin/bash -ev

# create new repositories
work_dir=/scratch/training.large.setup/
rm -rf ${work_dir}
svn export /scratch/workspace/documentation.gda/training_template/ ${work_dir}

for repository in $(ls -1 ${work_dir}); do
    echo -e "\n\n*********** processing ${repository} ***********\n"

    cd ${work_dir}${repository}
    git init
    git config user.name "Diamond Light Source"
    git config user.email "gda@diamond.ac.uk"
    git remote add origin dascgitolite@dasc-git.diamond.ac.uk:training/template/${repository}

    # populate the master branch and commit
    for item in $(ls -1); do
        echo "Let's call this version trunk" > $item/version.txt    # create new file
    done
    git add -A
    git commit -m "Initial \"trunk\" commit"                        # commit to local repository
    git push origin master

    # create a new 8.14 branch and commit
    git checkout -b 8.14
    for item in $(ls -1); do
        sed --in-place 's/trunk/8.14/' $item/version.txt            # modify existing file
    done
    git add -A
    git commit -m "Make 8.14 branch"                                # commit to local repository

    # make a change on the 8.14 branch
    git checkout 8.14
    for item in $(ls -1); do
        echo "A file added to 8.14" > $item/added-to-8.14.txt       # create new file
    done
    git add -A
    git commit -m "Add new files in 8.14"                           # commit to local repository
    git branch
    git push origin 8.14
    git status

    # make a change on trunk
    git checkout master
    for item in $(ls -1); do
        echo "Added post-8.14 file" > $item/added-to-trunk-after-8.14.txt     # create new file
    done
    git add -A
    git commit -m "Add new files after 8.14"                        # commit to local repository

    # create a new 8.16 branch and commit
    git checkout -b 8.16
    for item in $(ls -1); do
        sed --in-place 's/trunk/8.16/' $item/version.txt            # modify existing file
    done
    git add -A
    git commit -m "Make 8.16 branch"                                # commit to local repository

    # make a change on the 8.16 branch
    git checkout 8.16
    for item in $(ls -1); do
        echo "A file added to 8.16" > $item/added-to-8.16.txt       # create new file
    done
    git add -A
    git commit -m "Add new files in 8.16"                           # commit to local repository
    git branch
    git push origin 8.16
    git status

    # make a change on trunk
    git checkout master
    for item in $(ls -1); do
        echo "Added post-8.16 file" > $item/added-to-trunk-after-8.16.txt     # create new file
    done
    git add -A
    git commit -m "Add new files after 8.16"                        # commit to local repository
    git branch
    git push origin master
    git status

done