@@ -192,6 +192,32 @@ clone_ssh ()
192192 _clone " ${ssh_repos[@]} "
193193}
194194
195+ checkout_and_pull_default_branch ()
196+ {
197+ local name=$1
198+ local dir_path=${2:- $1 }
199+ if [ -d " $name " ]; then
200+ DEFAULT_BRANCH=$( cd ${dir_path} ; git symbolic-ref refs/remotes/origin/HEAD | sed ' s@^refs/remotes/origin/@@' )
201+ # Try to switch branch and pull, but fail if there are uncommitted changes.
202+ if (cd " $dir_path " ; git checkout -q ${DEFAULT_BRANCH} && git pull -q --ff-only);
203+ then
204+ # Echo untracked files to simplify debugging and make it easier to see that resetting does not remove everything
205+ untracked_files=" $( cd ${dir_path} && git ls-files --others --exclude-standard) "
206+ if [[ $untracked_files ]];
207+ then
208+ echo " The following untracked files are in ${name} repository:"
209+ echo " $untracked_files "
210+ fi
211+ else
212+ echo >&2 " Failed to reset $name repo. Exiting."
213+ echo >&2 " Please go to the repo and clean up any issues that are keeping 'git checkout $DEFAULT_BRANCH ' and 'git pull' from working."
214+ exit 1
215+ fi
216+ else
217+ printf " The [%s] repo is not cloned. Skipping.\n" " $name "
218+ fi
219+ }
220+
195221reset ()
196222{
197223 read -p " This will switch to the default branch and pull changes in your local git checkouts. Would you like to proceed? [y/n] " -r
@@ -207,28 +233,14 @@ reset ()
207233 exit 1
208234 fi
209235 name=" ${BASH_REMATCH[1]} "
210-
211- if [ -d " $name " ]; then
212- DEFAULT_BRANCH=$( cd ${name} ; git symbolic-ref refs/remotes/origin/HEAD | sed ' s@^refs/remotes/origin/@@' )
213- # Try to switch branch and pull, but fail if there are uncommitted changes.
214- if (cd " $name " ; git checkout -q ${DEFAULT_BRANCH} && git pull -q --ff-only);
215- then
216- # Echo untracked files to simplify debugging and make it easier to see that resetting does not remove everything
217- untracked_files=" $( cd ${name} && git ls-files --others --exclude-standard) "
218- if [[ $untracked_files ]];
219- then
220- echo " The following untracked files are in ${name} repository:"
221- echo " $untracked_files "
222- fi
223- else
224- echo >&2 " Failed to reset $name repo. Exiting."
225- echo >&2 " Please go to the repo and clean up any issues that are keeping 'git checkout $DEFAULT_BRANCH ' and 'git pull' from working."
226- exit 1
227- fi
228- else
229- printf " The [%s] repo is not cloned. Skipping.\n" " $name "
230- fi
236+ checkout_and_pull_default_branch " $name "
231237 done
238+
239+ echo " Updating edx-themes repo..."
240+ themes_directory=" src/edx-themes"
241+ if [ -d " $themes_directory " ]; then
242+ checkout_and_pull_default_branch " edx-themes" " $themes_directory "
243+ fi
232244}
233245
234246status ()
0 commit comments