Unverified Commit e0c0b2c5 authored by Wolfgang Walther's avatar Wolfgang Walther
Browse files

ci/github-script/merge: improve feedback for by-name check

The by-name check would previously be green when the
`pkgs/by-name/README.md` file was changed. This would still not mean the
maintainer was able to merge the PR, because there'd be no maintainer
for that file, but the feedback was not 100% accurate.
parent 42d395e0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ These issues effectively list PRs the merge bot has interacted with.
To ensure security and a focused utility, the bot adheres to specific limitations:

- The PR targets one of the [development branches](#branch-classification).
- The PR only touches packages located under `pkgs/by-name/*`.
- The PR only touches files of packages located under `pkgs/by-name/*`.
- The PR is either:
  - approved by a [committer][@NixOS/nixpkgs-committers].
  - authored by a [committer][@NixOS/nixpkgs-committers].
+5 −3
Original line number Diff line number Diff line
@@ -10,13 +10,15 @@ function runChecklist({
  user,
  userIsMaintainer,
}) {
  const allByName = files.every(({ filename }) =>
    filename.startsWith('pkgs/by-name/'),
  const allByName = files.every(
    ({ filename }) =>
      filename.startsWith('pkgs/by-name/') && filename.split('/').length > 4,
  )

  const packages = files
    .filter(({ filename }) => filename.startsWith('pkgs/by-name/'))
    .map(({ filename }) => filename.split('/')[3])
    .filter(Boolean)

  const eligible = !packages.length
    ? new Set()
@@ -40,7 +42,7 @@ function runChecklist({
  const checklist = {
    'PR targets a [development branch](https://github.com/NixOS/nixpkgs/blob/-/ci/README.md#branch-classification).':
      classify(pull_request.base.ref).type.includes('development'),
    'PR touches only packages in `pkgs/by-name/`.': allByName,
    'PR touches only files of packages in `pkgs/by-name/`.': allByName,
    'PR is at least one of:': {
      'Approved by a committer.': committers.intersection(approvals).size > 0,
      'Authored by a committer.': committers.has(pull_request.user.id),