Fix incorrect handling when unfetched packages are deleted from upstream - #4695
Fix incorrect handling when unfetched packages are deleted from upstream#4695aravindtga wants to merge 2 commits into
Conversation
Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
✅ Deploy Preview for kptdocs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Fixes update behavior when upstream deletes a subpackage that is still “unfetched” (origin only has a Kptfile), by fetching origin content at the locked commit before diffing so unchanged subpackages can be deleted correctly.
Changes:
- Add support for fetching a package at a specific commit SHA via
fetch.Command{Commit: ...}. - Update cloning logic to use the provided commit (or resolved ref) and factor tag lookup into
checkPackageTags. - Add/update tests covering commit-pinned fetch and deletion of unfetched subpackages during update.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/lib/util/fetch/fetch.go | Adds Commit support and refactors ref/tag resolution logic in the cloner. |
| pkg/lib/util/fetch/fetch_test.go | Adds a test that validates fetching a specific commit vs branch tip behavior. |
| pkg/lib/update/update.go | Fetches origin at the local upstream-lock commit when origin is unfetched before diffing deleted subpackages. |
| pkg/lib/update/update_test.go | Adds tests covering deletion/retention of unfetched subpackages based on local changes. |
| commands/pkg/update/cmdupdate_test.go | Adds CLI-level test coverage for unfetched subpackage deletion behavior and output. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
Description
updatePackagefunction inpkg/lib/update/update.godetects the unfetched origin state viapkg.IsPackageUnfetched(), reads the commit SHA from the localupstreamLock, fetches origin at that exact commit using a newCommitfield onfetch.Command, adds merge comments, and then performs the diff as before.This PR is based on #2230, which was authored against the old codebase structure (when packages lived under
internal/). That PR was never merged. These changes port the same approach to the current codebase (packages now underpkg/lib/) with adapted API signatures and additional test coverage.Related Issue(s)
Type of Change
Checklist
AI Disclosure
If so, please describe how:
- Amazon Q Developer CLI to port and review the changes against the original PR #2230 and perform manual end-to-end testing and to draft the PR Message.