@@ -198,6 +198,32 @@ clone_ssh ()
198198 _clone " ${ssh_repos[@]} "
199199}
200200
201+ checkout_and_pull_default_branch ()
202+ {
203+ local name=$1
204+ local dir_path=${2:- $1 }
205+ if [ -d " $name " ]; then
206+ DEFAULT_BRANCH=$( cd ${dir_path} ; git symbolic-ref refs/remotes/origin/HEAD | sed ' s@^refs/remotes/origin/@@' )
207+ # Try to switch branch and pull, but fail if there are uncommitted changes.
208+ if (cd " $dir_path " ; git checkout -q ${DEFAULT_BRANCH} && git pull -q --ff-only);
209+ then
210+ # Echo untracked files to simplify debugging and make it easier to see that resetting does not remove everything
211+ untracked_files=" $( cd ${dir_path} && git ls-files --others --exclude-standard) "
212+ if [[ $untracked_files ]];
213+ then
214+ echo " The following untracked files are in ${name} repository:"
215+ echo " $untracked_files "
216+ fi
217+ else
218+ echo >&2 " Failed to reset $name repo. Exiting."
219+ echo >&2 " Please go to the repo and clean up any issues that are keeping 'git checkout $DEFAULT_BRANCH ' and 'git pull' from working."
220+ exit 1
221+ fi
222+ else
223+ printf " The [%s] repo is not cloned. Skipping.\n" " $name "
224+ fi
225+ }
226+
201227reset ()
202228{
203229 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
@@ -213,28 +239,14 @@ reset ()
213239 exit 1
214240 fi
215241 name=" ${BASH_REMATCH[1]} "
216-
217- if [ -d " $name " ]; then
218- DEFAULT_BRANCH=$( cd ${name} ; git symbolic-ref refs/remotes/origin/HEAD | sed ' s@^refs/remotes/origin/@@' )
219- # Try to switch branch and pull, but fail if there are uncommitted changes.
220- if (cd " $name " ; git checkout -q ${DEFAULT_BRANCH} && git pull -q --ff-only);
221- then
222- # Echo untracked files to simplify debugging and make it easier to see that resetting does not remove everything
223- untracked_files=" $( cd ${name} && git ls-files --others --exclude-standard) "
224- if [[ $untracked_files ]];
225- then
226- echo " The following untracked files are in ${name} repository:"
227- echo " $untracked_files "
228- fi
229- else
230- echo >&2 " Failed to reset $name repo. Exiting."
231- echo >&2 " Please go to the repo and clean up any issues that are keeping 'git checkout $DEFAULT_BRANCH ' and 'git pull' from working."
232- exit 1
233- fi
234- else
235- printf " The [%s] repo is not cloned. Skipping.\n" " $name "
236- fi
242+ checkout_and_pull_default_branch " $name "
237243 done
244+
245+ echo " Updating edx-themes repo..."
246+ themes_directory=" src/edx-themes"
247+ if [ -d " $themes_directory " ]; then
248+ checkout_and_pull_default_branch " edx-themes" " $themes_directory "
249+ fi
238250}
239251
240252status ()
0 commit comments