Skip to content

Add go-mod-sync-kopia hook for oadp-vmdp rebase#100

Closed
Joeavaikath wants to merge 0 commit into
oadp-rebasebot:oadp-devfrom
Joeavaikath:oadp-dev
Closed

Add go-mod-sync-kopia hook for oadp-vmdp rebase#100
Joeavaikath wants to merge 0 commit into
oadp-rebasebot:oadp-devfrom
Joeavaikath:oadp-dev

Conversation

@Joeavaikath

@Joeavaikath Joeavaikath commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a new post-rebase hook go-mod-sync-kopia.sh that resets go.mod to the migtools/kopia source before go mod tidy runs. 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

  1. go-mod-sync-kopia.sh runs git checkout source/$REBASEBOT_SOURCE -- go.mod to restore kopia's go.mod
  2. go-mod-tidy-and-commit.sh then runs go mod tidy, adding any extra deps oadp-vmdp needs on top of the kopia base

Test plan

Summary by CodeRabbit

  • New Features
    • Added an automated post-rebase step to keep go.mod in sync with the upstream source copy.
    • Updated rebase workflows to run this sync step before the existing dependency cleanup steps.
    • Added a new hook script that applies the upstream go.mod version and commits the change only when needed.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new hook script, go-mod-sync-kopia.sh, that checks out go.mod from an upstream source directory and commits it if changed. Registers this script in the HOOK_SCRIPTS sequence of two rebase config files, running before go-mod-tidy-and-commit.sh.

Changes

go-mod-sync-kopia Hook

Layer / File(s) Summary
New sync script
rebasebot-hook-scripts/go-mod-sync-kopia.sh
New script validates REBASEBOT_SOURCE, checks out go.mod from source/${REBASEBOT_SOURCE}, and conditionally stages/commits changes with optional author info from REBASEBOT_GIT_USERNAME/REBASEBOT_GIT_EMAIL.
Hook chain wiring
rebase-configs/migtools_oadp_vmdp_oadp-1.6.env.sh, rebase-configs/migtools_oadp_vmdp_oadp-dev.env.sh
HOOK_SCRIPTS lists in both config files now include go-mod-sync-kopia.sh before go-mod-tidy-and-commit.sh.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Suggested reviewers: kaovilai

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the added go-mod-sync-kopia hook and the affected oadp-vmdp rebase configs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 13a971d and 75afb65.

📒 Files selected for processing (3)
  • rebase-configs/migtools_oadp_vmdp_oadp-1.6.env.sh
  • rebase-configs/migtools_oadp_vmdp_oadp-dev.env.sh
  • rebasebot-hook-scripts/go-mod-sync-kopia.sh

Comment on lines +18 to +30
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
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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.

Suggested change
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants