FIX: Perform git operations as owning user (#672)
authorDavid Taylor <david@taylorhq.com>
Mon, 30 Jan 2023 16:06:46 +0000 (16:06 +0000)
committerGitHub <noreply@github.com>
Mon, 30 Jan 2023 16:06:46 +0000 (16:06 +0000)
The `git` version in our discourse_test docker image was recently updated to include a permissions check before running any git commands. For this to pass, git operations must be performed by the user which owns the git repository's directory.

templates/web.template.yml

index 9e645e6c5f93bc4a71526087b4975c103cbd6e5c..e574210d9a6ea250f2a1523a0337e1bd8e364be4 100644 (file)
@@ -86,12 +86,12 @@ run:
       cd: $home
       hook: code
       cmd:
-        - git reset --hard
-        - git clean -f
-        - git remote set-branches --add origin main
-        - git remote set-branches origin $version
-        - git fetch --depth 1 origin $version
-        - git checkout $version
+        - sudo -H -E -u discourse git reset --hard
+        - sudo -H -E -u discourse git clean -f
+        - sudo -H -E -u discourse git remote set-branches --add origin main
+        - sudo -H -E -u discourse git remote set-branches origin $version
+        - sudo -H -E -u discourse git fetch --depth 1 origin $version
+        - sudo -H -E -u discourse git checkout $version
         - mkdir -p tmp
         - chown discourse:www-data tmp
         - mkdir -p tmp/pids