git: always fetch specified source-commit before using
Metadata
Current evaluation
Merged. The git module now fetches the specified source-commit from origin before use, preventing failures when the commit is absent from local history or excluded by shallow clones. Approved by two reviewers and passed CI.
Suggested action: —
No scores available.
Issue body
Two cases where git will fail on specified source-commit:
- commit ID is not in specified branch history (or master, if no branch
is specified).
- source-depth is used which doesn't contain neccessary commit ID.
This commit changes the git module to fetch the reference from origin
before attempting to use it.
LP: #1817907
Signed-off-by: Chris Patterson <chris.patterson@canonical.com>
- [ ] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [ ] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [ ] Have you successfully run `./runtests.sh static`?
- [ ] Have you successfully run `./runtests.sh tests/unit`?
-----
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Merged. The git module now fetches the specified source-commit from origin before use, preventing failures when the commit is absent from local history or excluded by shallow clones. Approved by two reviewers and passed CI. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged a fix for the git module that fails when a specified source-commit is absent from local history or depth-limited clones. The change fetches the reference from origin before use, resolving LP #1817907. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged. Resolves LP #1817907 by fetching the specified source-commit from origin before use, preventing git failures when the commit is missing from branch history or excluded by shallow depth. Approved by @hellsworth. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1476 fix(git-source): only shallow fetch if a source-depth is provided | craft-parts | merged | Merged fix making git shallow fetch opt-in, applying only when source-depth is explicitly non-zero. Prevents unintended shallow clones that broke cherry-pick builds. Approved by three reviewers and merged to hotfix/2.28 for craft parts 2.28.0. |