fix(git-source): only shallow fetch if a source-depth is provided
Metadata
Current evaluation
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.
Suggested action: —
No scores available.
Issue body
- [ ] Have you followed the guidelines for contributing?
- [ ] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [ ] Have you successfully run `make lint && make test`?
- [ ] Have you added an entry to the changelog (`docs/reference/changelog.rst`)?
---
Reported [via Mattermost](https://chat.canonical.com/canonical/pl/9ht41p6z7fyqzrrenzk59mhkyc).
Specifying a full-length commit hash in `source-commit` would force you to do a shallow clone, regardless of the value of `source-depth`. `source-depth: 0` was equivalent to `source-depth: 1`.
This PR patches the shallow commit behavior to only happen if a non-zero source depth was specified, making it more opt-in and avoiding breakages for builds that depend on cherry-picking.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | 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. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1378 fix: shallow clone with source-commit if possible | craft-parts | merged | Merged to resolve issue #1360 and CRAFT-4853. Optimizes shallow cloning when a source commit is available. Approved by two reviewers, passed all CI checks, and modified three files with 233 additions and 20 deletions. | |
| #248 Git source: Make a shallow clone. | snapcraft | merged | Merged changes to the git source that replace full history fetches with a depth-1 shallow clone, resolving Launchpad bug #1536696. The update modifies two files and received reviewer approval. | |
| #2968 git: always fetch specified source-commit before using | snapcraft | merged | 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. | |
| #6067 fix: allow for deep clones with source-commit | snapcraft | merged | Merged a fix that bumps the Craft Parts dependency to enable deep clones with source-commit. Approved by two reviewers, passed CI checks, and updated two files. |