Add go-mod-sync-kopia hook for oadp-vmdp rebase#100
Conversation
📝 WalkthroughWalkthroughAdds a new hook script, Changesgo-mod-sync-kopia Hook
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rebasebot-hook-scripts/go-mod-sync-kopia.sh`:
- Around line 18-30: The stage_and_commit function is committing all dirty files
instead of only go.mod. Update the staging check and git add behavior in
stage_and_commit so it scopes to go.mod (and only commits when that file has
changes), rather than using git status --porcelain and git add -A. Keep the
existing author_flag logic and commit message intact while ensuring unrelated
files are not included.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 584e36c1-05bd-4a40-85b3-a5728a1d5439
📒 Files selected for processing (3)
rebase-configs/migtools_oadp_vmdp_oadp-1.6.env.shrebase-configs/migtools_oadp_vmdp_oadp-dev.env.shrebasebot-hook-scripts/go-mod-sync-kopia.sh
| stage_and_commit(){ | ||
| if [[ -z "${REBASEBOT_GIT_USERNAME:-}" || -z "${REBASEBOT_GIT_EMAIL:-}" ]]; then | ||
| author_flag=() | ||
| else | ||
| author_flag=(--author="$REBASEBOT_GIT_USERNAME <$REBASEBOT_GIT_EMAIL>") | ||
| fi | ||
|
|
||
| if [[ -n $(git status --porcelain) ]]; then | ||
| git add -A | ||
| git commit "${author_flag[@]}" -q \ | ||
| -m "UPSTREAM: <drop>: sync go.mod from kopia source" | ||
| fi | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Scope the commit to go.mod only.
git status --porcelain (unscoped) and git add -A will stage and commit any dirty working-tree files, not just go.mod. If earlier hook steps or stray untracked files leave the tree dirty, they'll be swept into this commit under the misleading message "sync go.mod from kopia source," corrupting commit provenance.
🔧 Proposed fix to scope staging/commit to go.mod
if [[ -n $(git status --porcelain) ]]; then
- git add -A
+ git add go.mod
git commit "${author_flag[@]}" -q \
-m "UPSTREAM: <drop>: sync go.mod from kopia source"
fi📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| stage_and_commit(){ | |
| if [[ -z "${REBASEBOT_GIT_USERNAME:-}" || -z "${REBASEBOT_GIT_EMAIL:-}" ]]; then | |
| author_flag=() | |
| else | |
| author_flag=(--author="$REBASEBOT_GIT_USERNAME <$REBASEBOT_GIT_EMAIL>") | |
| fi | |
| if [[ -n $(git status --porcelain) ]]; then | |
| git add -A | |
| git commit "${author_flag[@]}" -q \ | |
| -m "UPSTREAM: <drop>: sync go.mod from kopia source" | |
| fi | |
| } | |
| stage_and_commit(){ | |
| if [[ -z "${REBASEBOT_GIT_USERNAME:-}" || -z "${REBASEBOT_GIT_EMAIL:-}" ]]; then | |
| author_flag=() | |
| else | |
| author_flag=(--author="$REBASEBOT_GIT_USERNAME <$REBASEBOT_GIT_EMAIL>") | |
| fi | |
| if [[ -n $(git status --porcelain) ]]; then | |
| git add go.mod | |
| git commit "${author_flag[@]}" -q \ | |
| -m "UPSTREAM: <drop>: sync go.mod from kopia source" | |
| fi | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@rebasebot-hook-scripts/go-mod-sync-kopia.sh` around lines 18 - 30, The
stage_and_commit function is committing all dirty files instead of only go.mod.
Update the staging check and git add behavior in stage_and_commit so it scopes
to go.mod (and only commits when that file has changes), rather than using git
status --porcelain and git add -A. Keep the existing author_flag logic and
commit message intact while ensuring unrelated files are not included.
Summary
Adds a new post-rebase hook
go-mod-sync-kopia.shthat resets go.mod to the migtools/kopia source beforego mod tidyruns. This prevents downstream carry commits from pinning stale dependency versions that drift behind kopia.The oadp-vmdp rebase configs (oadp-1.6 and oadp-dev) are updated to run this hook as the first step in the hook chain, before go-mod-tidy and normalize-dockerfiles.
Problem
oadp-vmdp had downstream carry commits that explicitly pinned older dependency versions (e.g., grpc v1.79.3, otel v1.42.0). When rebased onto the current kopia base, these carry commits would overwrite kopia's newer versions, cascading stale pins across all transitive dependencies.
How it works
go-mod-sync-kopia.shrunsgit checkout source/$REBASEBOT_SOURCE -- go.modto restore kopia's go.modgo-mod-tidy-and-commit.shthen runsgo mod tidy, adding any extra deps oadp-vmdp needs on top of the kopia baseTest plan
--local-hooks --dry-run— hook ran successfully, go mod tidy resolved to kopia-aligned versionsSummary by CodeRabbit
go.modin sync with the upstream source copy.go.modversion and commits the change only when needed.