Skip to content
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

🐛 Code-Review: change phabricator regex to allow URLs #4086

Merged
merged 1 commit into from
May 7, 2024

Conversation

spencerschrock
Copy link
Member

What kind of change does this PR introduce?

bug fix

What is the current behavior?

The old regex used \w which only allowed [0-9A-Za-z_], however most projects use full URLs with phabricator (e.g.
https://reviews.foo.org/D###). This led to errors parsing the revisions, where https was seen as the revision (the portion which matched \w), leading to an underreporting of code review practices as everything was considered 1 changeset.

go run main.go --repo freebsd/freebsd-src --checks Code-Review --format json --show-details | jq
{
  "date": "2024-05-06T14:23:32-07:00",
  "repo": {
    "name": "github.com/freebsd/freebsd-src",
    "commit": "a7db82cfd940431037e748280825931a46ed2d12"
  },
  "scorecard": {
    "version": "devel",
    "commit": "unknown"
  },
  "score": 0.0,
  "checks": [
    {
      "details": null,
      "score": 0,
      "reason": "Found 1/14 approved changesets -- score normalized to 0",
      "name": "Code-Review",
      "documentation": {
        "url": "https://github.com/ossf/scorecard/blob/main/docs/checks.md#code-review",
        "short": "Determines if the project requires human code review before pull requests (aka merge requests) are merged."
      }
    }
  ],
  "metadata": null
}

What is the new behavior (if this is a feature change)?**

The new regex focuses on matching D#### which is on the same line as "Differential Revision" . This regex does force the D prefix for a revision.

go run main.go --repo freebsd/freebsd-src --checks Code-Review --format json --show-details | jq
{
  "date": "2024-05-06T14:23:12-07:00",
  "repo": {
    "name": "github.com/freebsd/freebsd-src",
    "commit": "a7db82cfd940431037e748280825931a46ed2d12"
  },
  "scorecard": {
    "version": "devel",
    "commit": "unknown"
  },
  "score": 5.0,
  "checks": [
    {
      "details": null,
      "score": 5,
      "reason": "Found 17/30 approved changesets -- score normalized to 5",
      "name": "Code-Review",
      "documentation": {
        "url": "https://github.com/ossf/scorecard/blob/main/docs/checks.md#code-review",
        "short": "Determines if the project requires human code review before pull requests (aka merge requests) are merged."
      }
    }
  ],
  "metadata": null
}
  • Tests for the changes have been added (for bug fixes/features)

Which issue(s) this PR fixes

Fixes #4038

Special notes for your reviewer

I also made use of subtests in the corresponding test because it helps isolate the test failures better.

Does this PR introduce a user-facing change?

For user-facing changes, please add a concise, human-readable release note to
the release-note

(In particular, describe what changes users might need to make in their
application as a result of this pull request.)

Fixed an issue where Phabricator reviews weren't being parsed properly.

The old regex used \w which only allowed [0-9A-Za-z_], however most
projects use full URLs with phabricator (e.g.
https://reviews.foo.org/D###). This led to errors parsing the revisions,
where "https" was seen as the revision, leading to an underreporting of
code review practices.

The new regex focuses on the D#### part and uses it as the revision.

Signed-off-by: Spencer Schrock <sschrock@google.com>
@spencerschrock spencerschrock requested a review from a team as a code owner May 6, 2024 22:09
@spencerschrock spencerschrock requested review from naveensrinivasan and justaugustus and removed request for a team May 6, 2024 22:09
@spencerschrock
Copy link
Member Author

/scdiff generate Code-Review

Copy link

github-actions bot commented May 7, 2024

@spencerschrock spencerschrock merged commit 2506905 into ossf:main May 7, 2024
39 checks passed
@spencerschrock spencerschrock deleted the fix-phabricator-re branch May 7, 2024 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

BUG: Code-Review missing review markers
2 participants