Skip to content

on suggest target branch give exact command for release bot#94

Merged
sredxny merged 8 commits intomainfrom
TT-15793-give-exact-instructions-on-merging-branches
Nov 5, 2025
Merged

on suggest target branch give exact command for release bot#94
sredxny merged 8 commits intomainfrom
TT-15793-give-exact-instructions-on-merging-branches

Conversation

@sredxny
Copy link
Copy Markdown
Contributor

@sredxny sredxny commented Nov 5, 2025

On the comment posted in the PRs now we say exactly which command should be executed

@github-actions github-actions bot added enhancement New feature or request review/effort:1 labels Nov 5, 2025
@probelabs
Copy link
Copy Markdown

probelabs bot commented Nov 5, 2025

🔍 Code Analysis Results

This PR improves the branch suggestion comment by providing exact, copy-pasteable commands for the release bot. Instead of a generic example, the action will now post a comment with a specific list of /release to <branch> commands for all suggested release branches, streamlining the developer workflow for backporting fixes.

The logic for suggesting branches has been enhanced to prefer exact patch version branches (e.g., release-5.10.1) when they exist, falling back to minor version branches (e.g., release-5.10). The corresponding test file has been updated to cover these changes.

Files Changed Analysis

  • branch-suggestion/scripts/common/match-branches.js (+45, -7): The core logic has been updated.
    • generateBranchCandidates: Now adds exact patch versions (e.g., release-x.y.z) as the highest priority candidates.
    • getBranchReason & getBranchPriority: Modified to correctly handle and prioritize these new exact version branches.
    • formatBranchSuggestions: Rewritten to dynamically generate a list of specific /release to ... commands from the matched branches, using a Set to ensure uniqueness.
  • branch-suggestion/scripts/common/__tests__/match-branches.test.js (+50, -2): New unit tests have been added to validate the updated logic.
    • Tests now cover the generation and prioritization of exact patch version branches.
    • New test cases for matchBranches ensure that an exact version branch is preferred over a minor version branch when both are available.

Architecture & Impact Assessment

  • What this PR accomplishes: It makes the process of cherry-picking a merged PR to release branches more efficient and less error-prone by providing developers with the exact commands needed to trigger the release bot.
  • Key technical changes introduced:
    • The branch suggestion algorithm is now more precise, prioritizing release-x.y.z branches.
    • The output comment is dynamically generated with a list of actionable commands, tailored to the specific PR and its target versions.
  • Affected system components: The primary impact is on the user-facing comment posted by the branch-suggestion GitHub Action. This directly affects the developer workflow for creating backports via the release bot.

Visualization of the New Workflow

sequenceDiagram
    participant Developer
    participant GitHub PR
    participant Branch Suggestion Action
    participant Release Bot

    Developer->>GitHub PR: Merges PR to master
    Branch Suggestion Action->>GitHub PR: Posts comment with exact `/release to ...` commands
    Developer->>GitHub PR: Copies and pastes release commands into a new comment
    GitHub PR->>Release Bot: Triggers backport for each command
    Release Bot->>GitHub PR: Creates backport PRs
Loading

Scope Discovery & Context Expansion

  • The changes are well-contained within the branch-suggestion action.
  • The developer has added comprehensive tests for the updated logic in generateBranchCandidates, getBranchPriority, getBranchReason, and matchBranches, which addresses much of the feedback seen in previous review comments.
  • A remaining gap is the lack of unit tests for the refactored formatBranchSuggestions function. Since this function is responsible for generating the final user-facing comment, adding tests would be beneficial to prevent potential formatting issues or regressions.
Metadata
  • Review Effort: 2 / 5
  • Primary Label: enhancement

Powered by Visor from Probelabs

Last updated: 2025-11-05T18:44:41.719Z | Triggered by: synchronize | Commit: 6c42910

💡 TIP: You can chat with Visor using /visor ask <your question>

@probelabs
Copy link
Copy Markdown

probelabs bot commented Nov 5, 2025

🔍 Code Analysis Results

Security Issues (1)

Severity Location Issue
🟡 Warning branch-suggestion/scripts/common/match-branches.js:270
The script generates bot commands by embedding raw branch names from the repository. These branch names are not validated or sanitized. A maliciously crafted branch name containing special characters (e.g., newlines, semicolons, or other shell metacharacters) could potentially lead to command injection in the downstream release bot that processes these commands from PR comments.
💡 SuggestionValidate branch names against a strict regular expression before embedding them in the command string. For example, you could enforce a pattern like `/^release-\d+\.\d+(\.\d+)?$/` for release branches and explicitly check for `master`. This will prevent unexpected characters from being passed to the release bot, mitigating the risk of injection attacks.

Architecture Issues (1)

Severity Location Issue
🟡 Warning branch-suggestion/scripts/common/match-branches.js:31-37
The logic to add a minor version branch (e.g., `release-5.8`) to the list of candidates is duplicated. The condition on line 36 (`if (minor !== null)`) is a superset of the condition on line 31 (`if (patch !== null && patch > 0 && minor !== null)`), causing the same branch to be potentially added twice. While `new Set()` correctly de-duplicates the final list, the code can be simplified to avoid this redundancy.
💡 SuggestionCombine the two `if` statements into a single one that adds the minor version branch. The logic for both patch and minor releases can be covered by a single check for `minor !== null`.
🔧 Suggested Fix
    // Second priority: minor version branch (X.Y)
    if (minor !== null) {
        candidates.push(`release-${major}.${minor}`);
    }

✅ Performance Check Passed

No performance issues found – changes LGTM.

Quality Issues (1)

Severity Location Issue
🟡 Warning branch-suggestion/scripts/common/match-branches.js:30-37
The logic to add a minor version branch candidate (e.g., `release-5.8`) is duplicated. The condition `patch !== null && patch > 0 && minor !== null` is a subset of the subsequent condition `minor !== null`. This makes the first `if` block redundant, as the second block handles all necessary cases. While `new Set()` correctly deduplicates the candidates, the code is unnecessarily complex and can be simplified.
💡 SuggestionConsolidate the logic into a single condition to improve clarity and remove redundancy. The block checking for `patch > 0` can be removed entirely as it is covered by the subsequent check.
🔧 Suggested Fix
    // Second priority: minor version branch (X.Y)
    if (minor !== null) {
        candidates.push(`release-${major}.${minor}`);
    }

Powered by Visor from Probelabs

Last updated: 2025-11-05T18:44:43.312Z | Triggered by: synchronize | Commit: 6c42910

💡 TIP: You can chat with Visor using /visor ask <your question>

@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 5, 2025

🎯 Recommended Merge Targets

Based on JIRA ticket TT-15793: Implement Intelligent Branch Merge Recommendations


📋 Workflow

  1. Merge this PR to master first
  2. After merging, comment on the merged PR with /release to <branch> to cherry-pick to release branches
  3. Example: /release to release-5.8
  4. The bot will automatically create a backport PR to the specified release branch

@sredxny sredxny merged commit b6d30c6 into main Nov 5, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request review/effort:1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants