Skip to content

fix: handle squashed commits better during pre-push#1469

Merged
GHkrishna merged 1 commit intomainfrom
fix/hooks
Sep 30, 2025
Merged

fix: handle squashed commits better during pre-push#1469
GHkrishna merged 1 commit intomainfrom
fix/hooks

Conversation

@GHkrishna
Copy link
Copy Markdown
Contributor

@GHkrishna GHkrishna commented Sep 30, 2025

What

  • Handle squashed commits better during pre-push
  • Ease the skipping of merge commits when checking singoff. (We can skip then, as they are skipped by DCO too)

Summary by CodeRabbit

  • New Features

    • No user-facing changes.
  • Chores

    • Refined commit-signature check in pre-push tooling to flag only truly unsigned commits, reducing false positives. Maintains existing reporting of unsigned commits with no impact on runtime behavior.
  • Documentation

    • Improved inline comments explaining unsigned-commit detection, auto-signing considerations, and merge/rebase nuances, without altering rebase logic.

Signed-off-by: Krishna Waske <krishna.waske@ayanworks.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Sep 30, 2025

Walkthrough

Updates .husky/pre-push to treat only commits with signature status “N” as unsigned, adjusts related comments, and adds explanatory notes around auto-signing and rebase/merge considerations without altering core rebase logic.

Changes

Cohort / File(s) Summary
Husky pre-push hook
\.husky/pre-push
Change unsigned detection from “sig_status ≠ G” to “sig_status == N”; update comments to reflect narrowed condition; add explanatory comments around auto-signing and handling of merge/rebase scenarios; no functional change to rebase logic.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Dev as Developer
  participant Git as git push
  participant Hook as .husky/pre-push
  participant Repo as Local Repo

  Dev->>Git: git push
  Git->>Hook: Invoke pre-push
  Hook->>Repo: List outgoing commits
  loop For each commit
    Repo-->>Hook: sig_status (G/A/U/N/...)
    alt sig_status == N (no signature)
      Hook->>Hook: Collect as unsigned
    else Other statuses
      Hook->>Hook: Ignore for unsigned set
    end
  end
  alt Any unsigned commits
    Note over Hook: Optionally auto-sign<br/>Consider merge/rebase nuances
    Hook->>Repo: Rebase/auto-sign if applicable
    Repo-->>Hook: Result
    alt Success
      Hook-->>Git: Continue push
    else Error
      Hook-->>Git: Fail push
    end
  else None unsigned
    Hook-->>Git: Continue push
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • fix: check pre commits #1468 — Introduces the pre-push signing/enforcement script; this PR adjusts its signature-status check from “not G” to “N”.

Suggested labels

bug

Suggested reviewers

  • RinkalBhojani
  • sairanjit

Poem

A nibble of code in the pre-push breeze,
I twitch my ears at the letter N, please—
Only no-signs flagged, fewer false frights,
Rebase still steady through merge-lit nights.
Hop, sign, push—carrots aligned just right. 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the core intention to improve handling of squashed commits during the pre-push hook and aligns clearly with the PR’s stated objectives and changes.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/hooks

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
🧪 Early access (Sonnet 4.5): enabled

We are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience.

Note:

  • Public repositories are always opted into early access features.
  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

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

@sonarqubecloud
Copy link
Copy Markdown

@GHkrishna GHkrishna self-assigned this Sep 30, 2025
@GHkrishna GHkrishna marked this pull request as ready for review September 30, 2025 06:24
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
.husky/pre-push (1)

54-56: Consider clarifying the explanatory comments.

The added comments provide useful context about merge commit handling, but they could be more concise and decisive. The phrase "Not sure, if we really want to make it this complex" suggests uncertainty about the current approach.

Consider refactoring to be more definitive:

-      # Avoid flattening of merge commits
-      # Not sure, if we really want to make it this complex, ideally it should be fine even if we flatten merge commits.
-      # Unless, the merge commit appears on the local branch, when trying to sync with the upstreams
-      # If we face any issues doing this, we revert to either flattening or maybe check the '--rebase-merges' feasibility. Considering the requirement of git version
+      # Preserve merge commits during rebase to maintain branch structure.
+      # The --exec skips merge commits (parent count > 1) to avoid signing them.
+      # Note: If issues arise, consider using --rebase-merges (requires Git 2.18+) or allow flattening.
       git rebase --onto "$parent_commit" "$parent_commit" \

However, based on your learnings preference for automatic rebase, the current verbose approach may be intentional for documentation purposes.

Based on learnings.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1a85484 and 63ee5a4.

📒 Files selected for processing (1)
  • .husky/pre-push (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: GHkrishna
PR: credebl/platform#1468
File: .husky/pre-push:47-56
Timestamp: 2025-09-29T12:14:52.466Z
Learning: User GHkrishna prefers allowing automatic rebase in pre-push hooks for signing commits, considering it acceptable since they're rebasing their own local commits before sharing.
📚 Learning: 2025-09-29T12:14:52.466Z
Learnt from: GHkrishna
PR: credebl/platform#1468
File: .husky/pre-push:47-56
Timestamp: 2025-09-29T12:14:52.466Z
Learning: User GHkrishna prefers allowing automatic rebase in pre-push hooks for signing commits, considering it acceptable since they're rebasing their own local commits before sharing.

Applied to files:

  • .husky/pre-push

Comment thread .husky/pre-push
@GHkrishna GHkrishna merged commit a8dff91 into main Sep 30, 2025
8 checks passed
@GHkrishna GHkrishna deleted the fix/hooks branch September 30, 2025 06:37
ankita-p17 pushed a commit that referenced this pull request Sep 30, 2025
Signed-off-by: Krishna Waske <krishna.waske@ayanworks.com>
Signed-off-by: Ankita Patidar <ankita.patidar@ayanworks.com>
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