building part with git source-commit not found in master fails
Metadata
Current evaluation
Fixed in snapcore/snapcraft#2968 (commit 3941e7918): Snapcraft now fetches a specified source-commit before checkout, including commits outside the default branch.
Resolution: closed resolved
Reason: PR #2968 was merged as commit 3941e7918, ensuring the requested commit is fetched before checkout. This resolves failures caused by shallow clones or commits not reachable from the default branch.
Evaluated by: mr-cal-bot
No scores available.
Issue body
As part of a CI build, I insert a source-commit property into a part definition corresponding to the revision under test. However, this seems to fail for revisions not in master (e.g. an auto-merge revision ID belonging to a github pull request). For example:
https://gitlab.gnome.org/jamesh/gtk-common-themes/-/jobs/229568
The failed command in question here is:
git -C .../parts/yaru/src checkout c324c18dc78f7b33b660b14797db993d1da852b5
I can reproduce this locally using commands roughly equivalent to what Snapcraft issues:
$ git clone https://github.com/ubuntu/yaru.git
...
$ cd yaru
$ git checkout c324c18dc78f7b33b660b14797db993d1da852b5
fatal: reference is not a tree: c324c18dc78f7b33b660b14797db993d1da852b5
The revision in question does exist in the remote repository though, and I can retrieve it with a fetch command:
$ git fetch origin c324c18dc78f7b33b660b14797db993d1da852b5
remote: Enumerating objects: 24, done.
remote: Counting objects: 100% (24/24), done.
remote: Compressing objects: 100% (24/24), done.
remote: Total 24 (delta 9), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (24/24), done.
From https://github.com/ubuntu/yaru
* branch c324c18dc78f7b33b660b14797db993d1da852b5 -> FETCH_HEAD
From that point, I can access the revision with "git checkout" or "git reset".
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Fixed in snapcore/snapcraft#2968 (commit 3941e7918): Snapcraft now fetches a specified source-commit before checkout, including commits outside the default branch. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed shallow Git builds by fetching source-commit before checkout; merged in snapcore/snapcraft#2968 (commit 3941e7918). | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed by merged PR #2968 (commit 3941e7918): Snapcraft now fetches an explicitly requested source-commit from origin before checkout, including shallow-clone cases. | |
| stealth/space-bunny-alpha | — | closed stale | Closed without a fix after 2219 days of inactivity; the missing Git commit would need to be fetched before checkout. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution due to inactivity. Snapcraft fails to checkout non-master git commits without a prior fetch, leaving the issue abandoned. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution. Snapcraft failed to checkout git commits not in master, such as PR auto-merge revisions. No fix was implemented. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution. The report describes Snapcraft failing to checkout git commits not in the default branch due to missing fetches, but no fix or discussion was recorded. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed without resolution or comments, likely abandoned. Snapcraft failed to checkout non-master git commits, requiring an explicit fetch. No fix or merge details provided. |
Update history
| Date | Change |
|---|---|
| created |
Related work
-
Likely Fixed By:
snapcore/snapcraft#2968
(confidence 100%)
Merged fix titled "git: always fetch specified source-commit before using," recorded as commit 3941e7918.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1614520 parser fails when getting git sources that have merge conflicts | snapcraft (launchpad) | closed | Fixed by snapcore/snapcraft#1052, merged as commit d22880fdc, making Git pulls more resilient to history changes and merge conflicts. | |
| #1999219 snapcraft checks only default branch for submodules | snapcraft (launchpad) | closed | Bug was upstream in craft-parts: git source cloned --recursive then checked out source-commit, so submodules were only fetched from the default branch. Fixed by craft-parts PR #1600 (commit d2845976); snapcraft issue closed once that landed. | |
| #1516228 missing " git://" in the source crashes the snapcraft | snapcraft (launchpad) | closed | Fixed in Snapcraft 0.5/master: a bare GitHub source no longer crashes and now reports "local source is not a directory" through pull-step handling (PR #448). | |
| #1979529 local git repositories cannot be cloned | snapcraft (launchpad) | closed | Local Git sources became cloneable in Snapcraft 7.1.1; the fix was merged via snapcraft#3861 in commit 4481326d6. |