Skip to content

Fix: Remove incorrect 'Closed' label for merged PRs in reviewed section #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

manhuu14
Copy link

@manhuu14 manhuu14 commented Jul 5, 2025

Fix incorrect "Closed" label for merged PRs in reviewed section

Refactored status logic to correctly display "Merged" for merged PRs, "Closed" for unmerged PRs, and no label for unknown statuses. Also added a helper function for merge status lookup and used the URL parser for safer repo extr

Summary by Sourcery

Correct PR review status labeling to distinguish merged, closed, and unknown review PR states.

Bug Fixes:

  • Show “Merged” label only for actually merged PRs
  • Show “Closed” label only for confirmed unmerged PRs

Enhancements:

  • Default to a neutral “open” label for unknown merge statuses
  • Refactor merge status logic to improve clarity and handling

- Fixed logic that showed 'Closed' label for merged PRs when merge status was unknown
- Now defaults to 'Open' label for unknown status instead of 'Closed'
- Addresses issue fossasia#176 where merged reviewed PRs incorrectly displayed 'Closed' label

Fixes fossasia#176
Copy link
Contributor

sourcery-ai bot commented Jul 5, 2025

Reviewer's Guide

This PR refactors the reviewed‐PR status logic in scrumHelper.js to explicitly handle merged, closed, and unknown cases, extracts merge‐status resolution into a helper function, and improves repository URL parsing for safer owner/repo lookup.

Class diagram for reviewed PR status logic in scrumHelper.js

classDiagram
    class scrumHelper {
        +renderReviewedPR(item, mergedStatusResults, repository_url, number, project, html_url, title)
    }
    class MergeStatusHelper {
        +getMergeStatus(mergedStatusResults, repository_url, number)
    }
    scrumHelper ..> MergeStatusHelper : uses
Loading

Flow diagram for reviewed PR status label rendering

flowchart TD
    A[PR state is 'closed'] --> B{Get merged status}
    B -->|merged === true| C[Show 'Merged' label]
    B -->|merged === false| D[Show 'Closed' label]
    B -->|merged is null/undefined| E[Show 'Open' or no label]
Loading

File-Level Changes

Change Details Files
Refactor closed‐state logic to handle merged, unmerged, and unknown explicitly
  • Split the single closed check into three branches for merged === true, merged === false, and merged === null/undefined
  • Assign pr_merged_button, pr_closed_button, or pr_open_button based on each branch
  • Remove default 'closed' label for unknown statuses and provide a neutral/none label option
src/scripts/scrumHelper.js
Extract merge‐status lookup into a helper function
  • Move mergedStatusResults lookup logic into a dedicated helper
  • Replace inline property access with helper calls for clarity and reuse
src/scripts/scrumHelper.js
Use URL parser for robust repository owner/repo extraction
  • Replace manual repository_url.split calls with new URL‐parsing utility
  • Handle edge cases in repository URLs to avoid indexing errors
src/scripts/scrumHelper.js

Possibly linked issues

  • #0: PR refactors status logic to correctly display Merged/Closed/Open states as requested by the issue.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @manhuu14 - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@manhuu14
Copy link
Author

manhuu14 commented Jul 5, 2025

can you merge this one

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.

1 participant