Skip to content

[fixes] Automate branch selection for porting changelog #646#647

Open
prathmeshkulkarni-coder wants to merge 1 commit intoopenwisp:masterfrom
prathmeshkulkarni-coder:issues/646-releaser-auto-branch-selection
Open

[fixes] Automate branch selection for porting changelog #646#647
prathmeshkulkarni-coder wants to merge 1 commit intoopenwisp:masterfrom
prathmeshkulkarni-coder:issues/646-releaser-auto-branch-selection

Conversation

@prathmeshkulkarni-coder
Copy link
Copy Markdown
Contributor

Implemented automated branch detection to avoid choosing between master and main when only one exists.

Fixes #646

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #646

Description of Changes

This PR automates the branch selection logic when porting changelogs during a bugfix release. Previously, the tool would always prompt the user to choose between master and main, even if only one of them existed.

Screenshot

Please include any relevant screenshots.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0f10eab4-c1f4-4bb2-8b19-228b0f20c54c

📥 Commits

Reviewing files that changed from the base of the PR and between 61d10ef and 1a5cf66.

📒 Files selected for processing (4)
  • openwisp_utils/releaser/release.py
  • openwisp_utils/releaser/tests/test_release.py
  • openwisp_utils/releaser/tests/test_utils.py
  • openwisp_utils/releaser/utils.py
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
  • GitHub Check: Python==3.13 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.1.0
  • GitHub Check: Python==3.13 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=4.2.0
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.0.0
  • GitHub Check: Python==3.10 | django~=5.1.0
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.11 | django~=5.0.0
  • GitHub Check: Python==3.12 | django~=4.2.0
  • GitHub Check: Python==3.10 | django~=5.0.0
  • GitHub Check: Python==3.11 | django~=4.2.0
  • GitHub Check: Python==3.10 | django~=5.2.0
  • GitHub Check: Kilo Code Review
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{py,html,txt}

📄 CodeRabbit inference engine (Custom checks)

For Django pull requests, ensure all user-facing strings are marked as translatable using the Django i18n framework

Files:

  • openwisp_utils/releaser/utils.py
  • openwisp_utils/releaser/tests/test_utils.py
  • openwisp_utils/releaser/release.py
  • openwisp_utils/releaser/tests/test_release.py
🧠 Learnings (5)
📚 Learning: 2026-03-14T20:44:14.568Z
Learnt from: CR
Repo: openwisp/openwisp-utils PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2026-03-14T20:44:14.568Z
Learning: Changes: Update tests to cover non-trivial changes and ensure proper validation of modified behavior

Applied to files:

  • openwisp_utils/releaser/tests/test_release.py
📚 Learning: 2026-03-14T20:44:14.568Z
Learnt from: CR
Repo: openwisp/openwisp-utils PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2026-03-14T20:44:14.568Z
Learning: Bug Fixes: Ensure the test is deterministic and not flaky - flag tests that depend on timing, sleeps, specific timezones, system time, randomness without fixed seed, race conditions, concurrency timing, network access, external services, filesystem state, environment-specific configuration, execution order, shared global state, hardcoded ports, or unawaited async operations

Applied to files:

  • openwisp_utils/releaser/tests/test_release.py
📚 Learning: 2026-03-14T20:44:14.568Z
Learnt from: CR
Repo: openwisp/openwisp-utils PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2026-03-14T20:44:14.568Z
Learning: Bug Fixes: Ensure the regression test fails if the patch is removed or commented out

Applied to files:

  • openwisp_utils/releaser/tests/test_release.py
📚 Learning: 2026-03-14T20:44:14.568Z
Learnt from: CR
Repo: openwisp/openwisp-utils PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2026-03-14T20:44:14.568Z
Learning: Features: Add tests for new features and ensure coverage does not decrease significantly; prefer Selenium browser tests for UI-impacting features

Applied to files:

  • openwisp_utils/releaser/tests/test_release.py
📚 Learning: 2026-03-14T20:44:14.568Z
Learnt from: CR
Repo: openwisp/openwisp-utils PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2026-03-14T20:44:14.568Z
Learning: Bug Fixes: Ensure a regression test is included that reproduces the bug scenario

Applied to files:

  • openwisp_utils/releaser/tests/test_release.py
🔇 Additional comments (5)
openwisp_utils/releaser/utils.py (1)

88-96: branch_exists implementation looks correct and reliable.

Using git show-ref --verify --quiet and evaluating returncode == 0 is a solid way to probe local branch presence for this flow.

openwisp_utils/releaser/tests/test_utils.py (1)

312-326: Good unit coverage for the new helper behavior.

These tests pin both positive and negative returncode paths, which makes the branch_exists contract explicit.

openwisp_utils/releaser/release.py (1)

180-196: Branch-selection flow now aligns with the requested behavior.

The decision tree correctly prompts only when both branches exist and auto-selects when exactly one exists; the neither-branch path exits cleanly.

openwisp_utils/releaser/tests/test_release.py (2)

185-286: Excellent branch-selection regression matrix in tests.

The new cases cover all meaningful branch-availability permutations plus user cancel, which strongly protects the new behavior from regressions.


352-384: Nice follow-through updating existing porting tests for branch_exists.

Patching branch_exists in these paths keeps the tests aligned with the new control flow and prevents accidental reliance on repository branch state.


📝 Walkthrough

Walkthrough

Added a helper function branch_exists(branch_name) that checks for a local Git branch. port_changelog_to_main now probes main and master via branch_exists: if both exist it prompts the user to choose; if only one exists it selects that branch automatically; if neither exists it prints a notice and returns without porting or creating a PR. Unit tests were added/updated to cover both-present, single-present (each), neither-present, and prompt-cancel scenarios.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Releaser
    participant LocalGit
    participant GitHub

    User->>Releaser: run port_changelog_to_main
    Releaser->>LocalGit: branch_exists("main")?
    LocalGit-->>Releaser: exists_main (true/false)
    Releaser->>LocalGit: branch_exists("master")?
    LocalGit-->>Releaser: exists_master (true/false)

    alt neither exists
        Releaser->>User: print notice and exit
    else both exist
        Releaser->>User: prompt select target branch
        User-->>Releaser: selected_branch or cancel
        alt user selected
            Releaser->>Releaser: update changelog for selected_branch
            Releaser->>GitHub: create PR target=selected_branch
        else user canceled
            Releaser->>User: exit without creating PR
        end
    else only main exists
        Releaser->>Releaser: update changelog for "main"
        Releaser->>GitHub: create PR target="main"
    else only master exists
        Releaser->>Releaser: update changelog for "master"
        Releaser->>GitHub: create PR target="master"
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title uses '[fixes]' instead of the required '[fix]' format and includes an issue number which is not part of the template specification. Change title to '[fix] Automate branch selection for porting changelog' to match the required format, or '[change]' if this is a broader change rather than a fix.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description is mostly complete with checked checklist items, reference to issue #646, and explanation of changes, though documentation was not updated.
Linked Issues check ✅ Passed The PR implementation fully addresses issue #646 requirements: branch existence checks with automatic selection when one exists, prompting only when both branches exist, and skipping when neither exists.
Out of Scope Changes check ✅ Passed All changes are scoped to implementing automated branch detection for the changelog porting feature as specified in issue #646; no unrelated modifications detected.
Bug Fixes ✅ Passed This PR implements an automated branch selection feature to reduce unnecessary prompts, not a bug fix. Issue #646 is classified as a '[change]' request for UX improvement.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

@kilo-code-bot
Copy link
Copy Markdown

kilo-code-bot bot commented Apr 10, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

The automated branch detection feature from Issue #646 has been reverted. The PR now contains bot improvements, changelog bot workflows, and Selenium test fixes.

Changes Since Last Review

  • Reverted: Automated branch detection removed from release.py - now always prompts user for branch selection
  • Removed: branch_exists() function and all related tests

Files Reviewed (18 files changed)

Bot Improvements:

  • .github/actions/bot-autoassign/stale_pr_bot.py - Added maintainer-waiting detection
  • .github/actions/bot-autoassign/tests/test_stale_pr_bot.py - Tests for new features
  • .github/actions/bot-ci-failure/analyze_failure.py - Transient failure detection, slow-test stripping, markdown fixes
  • .github/actions/bot-ci-failure/test_analyze_failure.py - Comprehensive tests

Changelog Bot Workflows:

  • .github/workflows/bot-changelog-runner.yml - Workflow runner
  • .github/workflows/bot-changelog-trigger.yml - PR review trigger
  • .github/workflows/reusable-bot-changelog.yml - Reusable workflow
  • .github/workflows/reusable-bot-ci-failure.yml - CI failure reusable workflow

Selenium Fixes:

  • openwisp_utils/tests/selenium.py - Fixed skip handling in parallel runner
  • tests/test_project/tests/test_selenium_skip.py - New tests

Documentation:

  • docs/developer/reusable-github-utils.rst - Updated workflow docs
  • docs/developer/test-utilities.rst - Updated test utilities

Testing

All functionality is well-tested. The reverted branch detection tests have been removed appropriately.


Reviewed by kimi-k2.5-0127 · 437,665 tokens

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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@openwisp_utils/releaser/release.py`:
- Around line 187-190: The current branch-selection block sets main_branch =
"master" even when both main_exists and master_exists are False; update the
logic in the same function/block that uses the main_exists and master_exists
variables (the branch-selection around main_branch) to explicitly check
master_exists and, if neither main_exists nor master_exists is True, raise a
clear RuntimeError (or custom exception) explaining that neither 'main' nor
'master' exist locally instead of defaulting to "master"; ensure the error
message references 'main' and 'master' so callers get an early, descriptive
failure.

In `@openwisp_utils/releaser/tests/test_release.py`:
- Around line 185-236: The tests calling port_changelog_to_main are missing a
patch for the external formatter and can invoke real formatting logic; patch
openwisp_utils.releaser.release.format_file_with_docstrfmt in each of the three
tests (test_port_changelog_only_master_exists,
test_port_changelog_only_main_exists,
test_port_changelog_both_branches_prompts_user) and set it to a no-op (e.g., a
MagicMock or simple stub) so the formatter is not executed during the test run;
keep existing patches (branch_exists, subprocess.run, update_changelog_file,
questionary) and ensure the patched format_file_with_docstrfmt is added to the
decorator list and its mock is passed into the test functions.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b4998e12-ceb2-4dc6-abd5-dea1fa8a11b0

📥 Commits

Reviewing files that changed from the base of the PR and between 98540a6 and 8c6dbb6.

📒 Files selected for processing (3)
  • openwisp_utils/releaser/release.py
  • openwisp_utils/releaser/tests/test_release.py
  • openwisp_utils/releaser/utils.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.13 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=4.2.0
  • GitHub Check: Python==3.12 | django~=5.0.0
  • GitHub Check: Python==3.12 | django~=4.2.0
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.10 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=5.2.0
  • GitHub Check: Python==3.10 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=4.2.0
  • GitHub Check: Python==3.11 | django~=5.0.0
  • GitHub Check: Python==3.13 | django~=5.2.0
  • GitHub Check: Python==3.10 | django~=5.0.0
  • GitHub Check: Kilo Code Review
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{py,html,txt}

📄 CodeRabbit inference engine (Custom checks)

For Django pull requests, ensure all user-facing strings are marked as translatable using the Django i18n framework

Files:

  • openwisp_utils/releaser/utils.py
  • openwisp_utils/releaser/release.py
  • openwisp_utils/releaser/tests/test_release.py
🧠 Learnings (1)
📚 Learning: 2026-03-14T20:44:14.568Z
Learnt from: CR
Repo: openwisp/openwisp-utils PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2026-03-14T20:44:14.568Z
Learning: Changes: Update tests to cover non-trivial changes and ensure proper validation of modified behavior

Applied to files:

  • openwisp_utils/releaser/tests/test_release.py
🔇 Additional comments (2)
openwisp_utils/releaser/utils.py (1)

88-97: Branch existence helper is correct for local-branch detection.

Line 90-96 uses git show-ref --verify --quiet and a return-code check, which cleanly implements the intended local branch presence probe.

openwisp_utils/releaser/tests/test_release.py (1)

158-183: Good coverage for the “both branches exist” prompt/cancel path.

This segment cleanly exercises the interactive branch-selection flow and cancellation behavior.

@openwisp-companion
Copy link
Copy Markdown

Flake8 and Commit Message Failures

Hello @prathmeshkulkarni-coder,
(Analysis for commit 8c6dbb6)

  • Flake8 Failure: There are unused imports and redefinitions in openwisp_utils/releaser/tests/test_release.py.

  • Fix: Remove the unused import unittest.mock.call and the redefinition of call on line 267.

  • Commit Message Failure: The commit message does not adhere to the expected format.

  • Fix: Ensure the commit message follows this structure:

[prefix] Capitalized title #<issue>

<description>

Fixes #<issue>

For example:

[releaser] Automate branch selection for porting changelog #646

Implemented automated branch detection to avoid choosing between
master and main when only one exists.

Fixes #646

@prathmeshkulkarni-coder prathmeshkulkarni-coder force-pushed the issues/646-releaser-auto-branch-selection branch from 8c6dbb6 to c58dd22 Compare April 10, 2026 17:15
@openwisp-companion
Copy link
Copy Markdown

QA Failures: Black and Flake8

Hello @prathmeshkulkarni-coder,
(Analysis for commit c58dd22)

The CI failed due to code style issues detected by Black and Flake8.

Fix:
Run the command openwisp-qa-format in the root of the repository to automatically fix these issues.

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@openwisp_utils/releaser/release.py`:
- Around line 192-194: Replace the grammatically incorrect print message in
release.py that currently prints "Could not find neither 'master' nor 'main'
branch locally. Skipping changelog porting." (the print(...) call shown in the
diff) with a corrected sentence such as "Could not find either 'master' or
'main' branch locally. Skipping changelog porting." so the CLI output is
grammatically correct and clear.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6f2a3979-8436-4cb3-b9c0-0be670c3838b

📥 Commits

Reviewing files that changed from the base of the PR and between 8c6dbb6 and c58dd22.

📒 Files selected for processing (3)
  • openwisp_utils/releaser/release.py
  • openwisp_utils/releaser/tests/test_release.py
  • openwisp_utils/releaser/utils.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
  • GitHub Check: Python==3.12 | django~=5.0.0
  • GitHub Check: Python==3.13 | django~=5.2.0
  • GitHub Check: Python==3.13 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=4.2.0
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=4.2.0
  • GitHub Check: Python==3.11 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=5.2.0
  • GitHub Check: Python==3.11 | django~=5.0.0
  • GitHub Check: Python==3.11 | django~=4.2.0
  • GitHub Check: Python==3.10 | django~=5.0.0
  • GitHub Check: Python==3.10 | django~=5.1.0
  • GitHub Check: Kilo Code Review
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{py,html,txt}

📄 CodeRabbit inference engine (Custom checks)

For Django pull requests, ensure all user-facing strings are marked as translatable using the Django i18n framework

Files:

  • openwisp_utils/releaser/utils.py
  • openwisp_utils/releaser/release.py
  • openwisp_utils/releaser/tests/test_release.py
🧠 Learnings (4)
📚 Learning: 2026-03-14T20:44:14.568Z
Learnt from: CR
Repo: openwisp/openwisp-utils PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2026-03-14T20:44:14.568Z
Learning: Changes: Update tests to cover non-trivial changes and ensure proper validation of modified behavior

Applied to files:

  • openwisp_utils/releaser/tests/test_release.py
📚 Learning: 2026-03-14T20:44:14.568Z
Learnt from: CR
Repo: openwisp/openwisp-utils PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2026-03-14T20:44:14.568Z
Learning: Bug Fixes: Ensure the test is deterministic and not flaky - flag tests that depend on timing, sleeps, specific timezones, system time, randomness without fixed seed, race conditions, concurrency timing, network access, external services, filesystem state, environment-specific configuration, execution order, shared global state, hardcoded ports, or unawaited async operations

Applied to files:

  • openwisp_utils/releaser/tests/test_release.py
📚 Learning: 2026-03-14T20:44:14.568Z
Learnt from: CR
Repo: openwisp/openwisp-utils PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2026-03-14T20:44:14.568Z
Learning: Bug Fixes: Ensure the regression test fails if the patch is removed or commented out

Applied to files:

  • openwisp_utils/releaser/tests/test_release.py
📚 Learning: 2026-03-14T20:44:14.568Z
Learnt from: CR
Repo: openwisp/openwisp-utils PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2026-03-14T20:44:14.568Z
Learning: Features: Add tests for new features and ensure coverage does not decrease significantly; prefer Selenium browser tests for UI-impacting features

Applied to files:

  • openwisp_utils/releaser/tests/test_release.py
🔇 Additional comments (5)
openwisp_utils/releaser/utils.py (1)

88-97: Branch existence helper looks correct and safe.

The implementation is side-effect free and correctly maps Git return codes to a boolean existence check.

openwisp_utils/releaser/release.py (1)

180-191: Branch-target selection now correctly implements the intended behavior.

Prompting only when both branches exist and auto-selecting otherwise is the right control flow.

Also applies to: 196-196

openwisp_utils/releaser/tests/test_release.py (3)

158-183: Good test update for the “both branches exist” path.

Mocking branch_exists here makes the branch-selection path explicit and keeps this test aligned with the new release logic.


185-262: Strong coverage for all branch-presence combinations.

These tests validate auto-selection (main/master), interactive selection when both exist, and early exit when neither exists.


328-356: Nice hardening of markdown/skip-PR tests with branch checks mocked.

Patching branch_exists in these cases removes ambiguity and keeps behavior deterministic across environments.

@prathmeshkulkarni-coder prathmeshkulkarni-coder force-pushed the issues/646-releaser-auto-branch-selection branch from c58dd22 to 63af5aa Compare April 10, 2026 17:23
@prathmeshkulkarni-coder
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 10, 2026

Coverage Status

coverage: 97.405% (-0.07%) from 97.476% — prathmeshkulkarni-coder:issues/646-releaser-auto-branch-selection into openwisp:master

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 10, 2026
@prathmeshkulkarni-coder prathmeshkulkarni-coder force-pushed the issues/646-releaser-auto-branch-selection branch from 3bb33ca to 61d10ef Compare April 11, 2026 03:52
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.

♻️ Duplicate comments (1)
openwisp_utils/releaser/release.py (1)

193-194: ⚠️ Potential issue | 🟡 Minor

Fix grammar in the “missing branches” message.

At Line 193, the sentence is grammatically incorrect (“branch were”). Please switch to plural or use “either/or”.

Suggested wording
-                "Neither 'master' nor 'main' branch were found locally. "
+                "Neither 'master' nor 'main' branches were found locally. "
                 "Skipping changelog porting."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openwisp_utils/releaser/release.py` around lines 193 - 194, The literal error
message string "Neither 'master' nor 'main' branch were found locally. Skipping
changelog porting." is grammatically incorrect; update it in
openwisp_utils/releaser/release.py (the message used where missing branches are
reported) to a correct form such as "Neither 'master' nor 'main' branches were
found locally. Skipping changelog porting." or alternately "Neither 'master' nor
'main' branch was found locally. Skipping changelog porting." to fix
subject-verb agreement.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@openwisp_utils/releaser/release.py`:
- Around line 193-194: The literal error message string "Neither 'master' nor
'main' branch were found locally. Skipping changelog porting." is grammatically
incorrect; update it in openwisp_utils/releaser/release.py (the message used
where missing branches are reported) to a correct form such as "Neither 'master'
nor 'main' branches were found locally. Skipping changelog porting." or
alternately "Neither 'master' nor 'main' branch was found locally. Skipping
changelog porting." to fix subject-verb agreement.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: fdca9abb-b07c-455f-b9e6-ac4d19367ee2

📥 Commits

Reviewing files that changed from the base of the PR and between 63af5aa and 61d10ef.

📒 Files selected for processing (4)
  • openwisp_utils/releaser/release.py
  • openwisp_utils/releaser/tests/test_release.py
  • openwisp_utils/releaser/tests/test_utils.py
  • openwisp_utils/releaser/utils.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
  • GitHub Check: Python==3.13 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.1.0
  • GitHub Check: Python==3.13 | django~=5.1.0
  • GitHub Check: Python==3.12 | django~=4.2.0
  • GitHub Check: Python==3.12 | django~=5.0.0
  • GitHub Check: Python==3.11 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=5.0.0
  • GitHub Check: Python==3.10 | django~=5.2.0
  • GitHub Check: Python==3.10 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=4.2.0
  • GitHub Check: Python==3.10 | django~=5.0.0
  • GitHub Check: Python==3.10 | django~=4.2.0
  • GitHub Check: Kilo Code Review
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{py,html,txt}

📄 CodeRabbit inference engine (Custom checks)

For Django pull requests, ensure all user-facing strings are marked as translatable using the Django i18n framework

Files:

  • openwisp_utils/releaser/tests/test_utils.py
  • openwisp_utils/releaser/utils.py
  • openwisp_utils/releaser/release.py
  • openwisp_utils/releaser/tests/test_release.py
🧠 Learnings (5)
📚 Learning: 2026-03-14T20:44:14.568Z
Learnt from: CR
Repo: openwisp/openwisp-utils PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2026-03-14T20:44:14.568Z
Learning: Changes: Update tests to cover non-trivial changes and ensure proper validation of modified behavior

Applied to files:

  • openwisp_utils/releaser/tests/test_release.py
📚 Learning: 2026-03-14T20:44:14.568Z
Learnt from: CR
Repo: openwisp/openwisp-utils PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2026-03-14T20:44:14.568Z
Learning: Bug Fixes: Ensure the test is deterministic and not flaky - flag tests that depend on timing, sleeps, specific timezones, system time, randomness without fixed seed, race conditions, concurrency timing, network access, external services, filesystem state, environment-specific configuration, execution order, shared global state, hardcoded ports, or unawaited async operations

Applied to files:

  • openwisp_utils/releaser/tests/test_release.py
📚 Learning: 2026-03-14T20:44:14.568Z
Learnt from: CR
Repo: openwisp/openwisp-utils PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2026-03-14T20:44:14.568Z
Learning: Bug Fixes: Ensure the regression test fails if the patch is removed or commented out

Applied to files:

  • openwisp_utils/releaser/tests/test_release.py
📚 Learning: 2026-03-14T20:44:14.568Z
Learnt from: CR
Repo: openwisp/openwisp-utils PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2026-03-14T20:44:14.568Z
Learning: Features: Add tests for new features and ensure coverage does not decrease significantly; prefer Selenium browser tests for UI-impacting features

Applied to files:

  • openwisp_utils/releaser/tests/test_release.py
📚 Learning: 2026-03-14T20:44:14.568Z
Learnt from: CR
Repo: openwisp/openwisp-utils PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2026-03-14T20:44:14.568Z
Learning: Bug Fixes: Ensure a regression test is included that reproduces the bug scenario

Applied to files:

  • openwisp_utils/releaser/tests/test_release.py
🔇 Additional comments (5)
openwisp_utils/releaser/utils.py (1)

88-96: branch_exists implementation is solid.

Clear and correct local-branch detection using git refs; return-code handling is straightforward.

openwisp_utils/releaser/tests/test_utils.py (1)

312-326: Good coverage for branch_exists behavior.

The new tests cover both return-code branches and verify lookup against refs/heads/<branch>.

openwisp_utils/releaser/release.py (1)

180-190: Branch auto-selection logic matches the requested behavior.

This correctly avoids prompting when only one of master/main exists and keeps prompting when both exist.

openwisp_utils/releaser/tests/test_release.py (2)

185-286: Excellent scenario coverage for branch-selection behavior.

These tests cover the full matrix (only master, only main, both, neither, cancelled) and lock in the regression surface for issue #646.


158-166: Good update to patch branch_exists in existing flow tests.

This keeps the tests deterministic while aligning older test paths with the new branch-detection behavior.
Based on learnings: "Changes: Update tests to cover non-trivial changes and ensure proper validation of modified behavior" and "Bug Fixes: Ensure the test is deterministic and not flaky - flag tests that depend on timing, sleeps, specific timezones, system time, randomness without fixed seed, race conditions, concurrency timing, network access, external services, filesystem state, environment-specific configuration, execution order, shared global state, hardcoded ports, or unawaited async operations".

Also applies to: 352-377

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 11, 2026
Implemented automated branch detection to avoid choosing between
master and main when only one exists.

Fixes openwisp#646
@prathmeshkulkarni-coder
Copy link
Copy Markdown
Contributor Author

@nemesifier ,The 0.07% coverage drop in selenium.py is unrelated to this PR I haven't modified that file. My changes in the releaser/ module maintained and increased coverage.

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.

[change] Releaser: avoid asking which branch to port change log to

3 participants