Mobrovac has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/194556

Change subject: Update service git repos with vagrant git-update as well
......................................................................

Update service git repos with vagrant git-update as well

vagrant git-update is a great tool for automatically updating all of the
MediaWiki repositories checked out in the VM. However, it did not cover
services installed via roles (traditionally put in /srv). This patch
adds that functionality to it.

Bug: T91668
Change-Id: I1cc453eebe4bfc9a56bd3f0337f86bfdf0f325d4
---
M puppet/modules/mediawiki/files/run-git-update
1 file changed, 18 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vagrant 
refs/changes/56/194556/1

diff --git a/puppet/modules/mediawiki/files/run-git-update 
b/puppet/modules/mediawiki/files/run-git-update
index 747bead..52022e8 100644
--- a/puppet/modules/mediawiki/files/run-git-update
+++ b/puppet/modules/mediawiki/files/run-git-update
@@ -10,26 +10,33 @@
 UPDATE_ERRORS=( )
 
 function pull {
+  git_cmd=git
+  # /srv dirs are all root, so use sudo in that case
+  [[ -O . ]] || git_cmd="sudo git"
   echo -e "\e[36m==> Updating $(pwd) ...\e[0m"
-  branch=$(expr $(git symbolic-ref HEAD) : 'refs/heads/\(.*\)')
+  branch=$(expr $($git_cmd symbolic-ref HEAD) : 'refs/heads/\(.*\)')
+  if [[ -z "$branch" ]]; then
+    $git_cmd checkout master
+    branch=$(expr $($git_cmd symbolic-ref HEAD) : 'refs/heads/\(.*\)')
+  fi
   err=''
   if [[ -n "$branch" ]]; then
-    remote=$(git config branch.${branch}.remote)
+    remote=$($git_cmd config branch.${branch}.remote)
     if [[ -n "$remote" ]]; then
-        url=$(git config --get remote.${remote}.url)
+        url=$($git_cmd config --get remote.${remote}.url)
         if [[ $url == ssh://* ]]; then
             # Convert remote git url from ssh:// to anonymous https://
             tempurl=$(echo $url | sed -e 's!ssh://[^@]\+@!https://!g' -e 
's!:29418!/r!g')
-            git pull $tempurl
+            $git_cmd pull $tempurl
         else
-            git pull
+            $git_cmd pull
         fi
         if [[ $? -ne 0 ]]; then
           # If we didn't successfully update (possibly because we're on
           # a local branch), leave the submodules alone.
           err="GIT PULL failed in $(pwd) for branch '$branch'"
         else
-          git submodule update --init --recursive
+          $git_cmd submodule update --init --recursive
           if [[ $? -ne 0 ]]; then
             err="GIT SUBMODULE UPDATE failed in $(pwd) for branch '$branch'"
           fi
@@ -49,6 +56,11 @@
   echo
 }
 
+for srvdir in $(find /srv -maxdepth 2 -type d -name .git -printf "%h\n"); do
+  cd "${srvdir}"
+  pull
+done
+
 cd "$MW_INSTALL_PATH"
 pull
 

-- 
To view, visit https://gerrit.wikimedia.org/r/194556
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1cc453eebe4bfc9a56bd3f0337f86bfdf0f325d4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: master
Gerrit-Owner: Mobrovac <mobro...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to