chainguard-dev/melange

git-checkout pipeline does not work with subtrees

sporkmonger opened this issue · 2 comments

It seems like the git package doesn't include the subtree command by default, so any repo that uses subtrees is missing files when checking out with this pipeline.

It's possible that this omission is also causing fairly surprising behavior in other packages. Clone operations with a subtree in the repo will succeed but the subtree's files will just be missing. Other packages that rely on git don't know that something is wrong because the clone succeeded, so the error messages end up being extremely challenging to debug. I think the git package probably should include subtree support by default.

Tried to take a shot at fixing this, but I'm still pretty new to melange.

diff --git a/git.yaml b/git.yaml
index b81f4e83f..e88a159aa 100644
--- a/git.yaml
+++ b/git.yaml
@@ -47,6 +47,14 @@ pipeline:
         INSTALLDIRS=vendor \
         install -j$(nproc)
 
+  - runs: |
+      cd contrib/subtree
+      make
+      make prefix=/usr \
+        DESTDIR="${{targets.destdir}}" \
+        install -j$(nproc)
+      cd -
+
   - runs: |
       mkdir -p "${{targets.destdir}}"/var/git
 
@@ -106,6 +114,20 @@ subpackages:
       pipeline:
         - runs: ls /usr/local/etc/profile.d/*.bash
 
+  # - name: "git-subtree"
+  #   description: "Subtree support for git"
+  #   dependencies:
+  #     runtime:
+  #       - git
+  #   pipeline:
+  #     - runs: |-
+  #         cd contrib/subtree
+  #         make
+  #         make prefix=/usr \
+  #           DESTDIR="${{targets.destdir}}" \
+  #           install -j$(nproc)
+  #         cd -
+
 update:
   enabled: true
   release-monitor:
@@ -141,3 +163,6 @@ test:
       runs: |
         git config --list | grep 'user.name=Wolfi' || exit 1
         git config --list | grep 'user.email=wolf@wolfi.dev' || exit 1
+    - name: Verify subtree installation
+      runs: |
+        git subtree add --prefix test_subtree HEAD --squash

Couldn't get it passing tests in either the main pipeline or in a subpackage. Maybe someone else will have better luck.