Skip to content

Commit

Permalink
Merge pull request #108 from C2SM/remote_changes
Browse files Browse the repository at this point in the history
Fix Remote Repository for Exercise 6
  • Loading branch information
AnnikaLau authored Apr 9, 2024
2 parents 99ad351 + 6f8a544 commit 82f8466
Showing 1 changed file with 35 additions and 15 deletions.
50 changes: 35 additions & 15 deletions beginner/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ reset () {

# determine main or master for default branch name
get_default_branch_name() {

# Attempt to identify the default branch by querying the remote repository
default_branch=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5)

Expand Down Expand Up @@ -97,15 +96,15 @@ init_simple_repo_remote () {
# Dynamically get the default branch name (main or master, based on the version of git)
default_branch=$(get_default_branch_name)
# Switch to the dynamically determined default branch
git checkout "$default_branch"
cd ../conference_planning
echo""
echo -e "\033[31m\033[1mYou've been automatically moved to the 'conference_planning' directory, where the 'Conference Planning' repository is ready for you to go on with your exercise.\033[0m"
echo""
echo "Your schedules:"
echo""
Expand Down Expand Up @@ -148,6 +147,7 @@ init_repo_remote () {
git add schedule_day1.txt .gitignore && git commit -m "Add schedule_day1"
# Edit schedule_day1.txt
ed -s schedule_day1.txt <<< $'/program/\na\n09:00-11:00: Poster session\n.\nw\nq' > /dev/null
git add * && git commit -m "Add poster sessions in the morning"
Expand All @@ -158,21 +158,32 @@ init_repo_remote () {
git add * && git commit -m "Add rest of daily program"
cd ..
git clone conference_planning conference_planning_remote
cd conference_planning_remote
# Clone non-bare remote repository
git clone conference_planning conference_planning_remote_tmp
# Navigate into the cloned repository directory and create update_schedules branch
cd conference_planning_remote_tmp
git checkout -b "updated_schedules"
# Dynamically get the default branch name (main or master, based on the version of git)
default_branch=$(get_default_branch_name)
head_ref=$(git symbolic-ref HEAD)
default_branch=$(basename "$head_ref")
# Switch to the dynamically determined default branch
git checkout "$default_branch"
cd ../conference_planning
cd ../
# Clone bare remote repository and remove non-bare repository
git clone --bare conference_planning_remote_tmp conference_planning_remote
rm -fr conference_planning_remote_tmp
cd conference_planning
echo""
echo -e "\033[31m\033[1mYou've been automatically moved to the 'conference_planning' directory, where the 'Conference Planning' repository is ready for you to go on with your exercise.\033[0m"
echo""
echo "Your schedules:"
echo""
Expand All @@ -181,7 +192,11 @@ init_repo_remote () {
commit_to_remote_by_third_party() {
cd $dir_at_startup
cd ../../beginners_git/conference_planning_remote
cd ../../beginners_git
git clone conference_planning_remote conference_planning_remote_tmp
cd conference_planning_remote_tmp
git checkout updated_schedules
cp ../conference_planning/schedule_day1.txt .
sed '3s/.*/09:00-11:00: Workshop Git for advanced/' schedule_day1.txt > schedule_day1_tmp.txt
Expand All @@ -193,6 +208,11 @@ commit_to_remote_by_third_party() {
# Switch to the dynamically determined default branch
git checkout "$default_branch"
cd ../conference_planning
cd ..
rm -fr conference_planning_remote
git clone --bare conference_planning_remote_tmp conference_planning_remote
rm -rf conference_planning_remote_tmp
cd conference_planning
}

0 comments on commit 82f8466

Please sign in to comment.