fix(git-source): only shallow fetch if a source-depth is provided
Metadata
Current evaluation
Merged as commit f1e2c927 (#1476): git-source now shallow-clones only when a non-zero source-depth is set, so full-hash source-commit no longer forces a shallow fetch. Released in craft-parts 2.28.1 and merged back via #1481.
Resolution: closed resolved
Reason: PR #1476 was approved and merged as commit f1e2c927 after being rebased onto the hotfix/2.28 branch; the fix appears in the 2.28.1 changelog entry dated 2026-02-25 and hotfix/2.28 was merged back to main in #1481.
Evaluated by: mr-cal-bot
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 |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged as commit f1e2c927 (#1476): git-source now shallow-clones only when a non-zero source-depth is set, so full-hash source-commit no longer forces a shallow fetch. Released in craft-parts 2.28.1 and merged back via #1481. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged #1476 (commit f1e2c927): git-source now shallow-fetches only when a non-zero source-depth is set, avoiding full-hash source-commit clones and preserving cherry-pick builds. | |
| 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 work
-
Related To:
canonical/craft-parts#1481
(confidence 90%)
Merge of hotfix/2.28 back into main, carrying the 2.28.1 release containing this fix.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #248 Git source: Make a shallow clone. | snapcraft | merged | Merged #248 (commit 6ebd8e68d; merge 321b13277), changing Git sources from full clones to depth-1 shallow clones and resolving LP #1536696. | |
| #1378 fix: shallow clone with source-commit if possible | craft-parts | merged | Merged PR #1378 as ae26318e: Git pulls now prefer a shallow fetch for source-commit when possible, with deep-fetch fallback, fixing #1360. | |
| #2968 git: always fetch specified source-commit before using | snapcraft | merged | Merged #2968 in commit 3941e7918; Git sources now fetch the requested source-commit from origin, fixing missing-commit and shallow-clone failures. | |
| #814 Make source-depth a parameter and opt-in | snapcraft | merged | Merged #814 in commit 190463c3c, making source-depth an explicit, opt-in part property instead of enabling shallow Git clones by default. | |
| #6067 fix: allow for deep clones with source-commit | snapcraft | merged | Merged #6067 as 8dd4ca40c, bumping Craft Parts to adopt #1476 and allow deep clones for source-commit builds. | |
| #1536696 Git source clones all history | snapcraft (launchpad) | closed | Fixed by merged PR canonical/snapcraft#248 (commit 6ebd8e68d, merge 321b13277): Git sources now use a depth-1 shallow clone instead of fetching full history. Maintainer kyrofa linked the PR as the fix for LP #1536696. | |
| #1965792 source-depth should propagate to git submodules | snapcraft (launchpad) | open | Feature request: source-depth only shallow-clones the parent repo; git submodule update runs without --depth, so submodule-heavy builds (e.g. qt5) fetch full submodule history. Untriaged, no maintainer response. |