Skip to content

[Changelog] Make the fragment check merge-aware in pre-commit - #7528

Open
hujc7 wants to merge 1 commit into
isaac-sim:developfrom
hujc7:jichuanh/changelog-check-merge-aware
Open

[Changelog] Make the fragment check merge-aware in pre-commit#7528
hujc7 wants to merge 1 commit into
isaac-sim:developfrom
hujc7:jichuanh/changelog-check-merge-aware

Conversation

@hujc7

@hujc7 hujc7 commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Merging develop into a branch no longer fails the local check changelog fragments hook whenever develop has compiled fragments since the fork point. The hook now measures a pending merge from the base branch's tip instead of the old fork point.

Description

tools/changelog/cli.py, PRDiff.from_git(include_worktree=True), diffed the worktree against merge-base(origin/<base>, HEAD). During git merge develop HEAD is still the pre-merge tip, so develop's commits since the fork point are in the worktree but not in HEAD and read as branch changes; the scheduled compile commits delete fragments, which trips the immutability rule and marks the compiled packages as missing a fragment (observed on #7161: 7 false immutability hits, 7 false missing packages, none genuine). When MERGE_HEAD exists, the diff base is now the newer of the two merge-bases. The three-dot diff CI uses is unchanged.

Fixes # (none)

Type of change

  • Bug fix

Release backport

  • Backport this pull request to the active release branch after it merges into develop

Test plan

  • python -m pytest tools/changelog/test/ 92 passed; the new test fails on develop and passes here
  • pre-commit on the changed files

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation (none needed: tooling only)
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • A package changelog fragment is not required because no source package changed
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

With --include-worktree the check diffs the worktree against the merge-base of
origin/<base> and HEAD. While a merge of the base branch is pending, HEAD is
still the pre-merge tip, so the base's own commits since the fork point sit in
the worktree and are reported as this branch's changes. The scheduled
changelog-compile commits delete fragments, so every develop merge after one
of them fails the immutability rule and reports the compiled packages as
missing a fragment.

When MERGE_HEAD exists, measure from the newer of the two merge-bases (HEAD's
and MERGE_HEAD's), which for a develop merge is develop's tip. The three-dot
diff used in CI is unchanged.
@hujc7

hujc7 commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator Author

run-ci

@hujc7
hujc7 marked this pull request as ready for review September 3, 2026 09:45
@hujc7
hujc7 requested a review from a team September 3, 2026 09:45
@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Sep 3, 2026

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isaac Lab Review Bot

The merge-aware diff-base selection narrowly fixes pending base-branch merges while leaving the CI three-dot diff path unchanged. One error-handling regression should be corrected before merge.

  • Design and architecture: Using MERGE_HEAD only for pending merges and advancing the diff base only when the candidate is newer is a well-scoped design that preserves the existing PRDiff structure and committed-diff behavior.
  • API: PRDiff.from_git retains its signature and return semantics. The intended behavior change is limited to selecting the local worktree diff target during a pending merge.
  • Implementation: The optional Git probes appropriately use return codes, but the initial mandatory merge-base lookup now suppresses failure and can pass None into subsequent subprocess argument lists, replacing a useful Git failure with an opaque TypeError. Keep that lookup checked while retaining lenient handling for optional merge-state probes.

Minor fixes needed. Posted 1 actionable finding inline.

Automated review; human maintainers own approval decisions.

Comment thread tools/changelog/cli.py
result = subprocess.run(["git", *args], capture_output=True, text=True, cwd=REPO_ROOT)
return result.stdout.strip() if result.returncode == 0 else None

diff_target = _git("merge-base", remote_base, "HEAD")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Warning · Implementation — Required merge-base failure now yields None

The replaced call used check=True, so a missing origin/<base> ref or unrelated histories raised CalledProcessError carrying git's message. _git swallows non-zero exit codes, so diff_target can become None and is passed straight into the git diff argument list (and into --is-ancestor), producing an opaque TypeError: expected str ... not NoneType. Keep this required lookup checked and use the lenient helper only for the optional MERGE_HEAD probes.

@greptile-apps

greptile-apps Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR makes local changelog-fragment checks aware of pending merges by selecting a newer applicable merge base when MERGE_HEAD exists.

  • Adds a small helper for non-throwing Git queries and merge-aware diff-target selection.
  • Adds an integration-style Git test covering a pending merge of the current base branch after fragment compilation.

Confidence Score: 4/5

The PR appears safe to merge, with a non-blocking regression in how invalid or unavailable base refs are reported by the local hook.

The intended pending-merge behavior is covered, but suppressing the initial merge-base error allows None to reach subprocess.run and replace the existing handled error with a traceback.

Files Needing Attention: tools/changelog/cli.py

Important Files Changed

Filename Overview
tools/changelog/cli.py Adds merge-aware worktree diff selection, but failed initial merge-base queries can now become uncaught TypeError exceptions.
tools/changelog/test/test_git_diff.py Adds focused coverage proving that base-branch fragment deletions are excluded during a pending merge.

Reviews (1): Last reviewed commit: "Make the changelog fragment check merge-..." | Re-trigger Greptile

Comment thread tools/changelog/cli.py
result = subprocess.run(["git", *args], capture_output=True, text=True, cwd=REPO_ROOT)
return result.stdout.strip() if result.returncode == 0 else None

diff_target = _git("merge-base", remote_base, "HEAD")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Preserve initial merge-base failures

When origin/develop is unavailable or has no common ancestor with HEAD, _git returns None, which is passed to subprocess.run and produces an unhandled TypeError instead of the existing concise Git error. Keep this initial query throwing, or explicitly handle its failure before using diff_target.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant