Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions ci/github-script/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,15 @@ module.exports = async ({ github, context, core, dry }) => {
pull_number,
per_page: 100,
})
const commitMessages = prCommits.map((c) => c.commit.message)
const commitSubjects = prCommits.map(
(c) => c.commit.message.split('\n')[0],
)

// Label new package PRs: "packagename: init at X.Y.Z"
// Exclude NixOS module commits like "nixos/timekpr: init at 0.5.8"
const newPackagePattern = /(?<!nixos\/\S+): init at\b/
const newPackagePattern = /^(?<!nixos\/)\S+: init at\b/
const hasNewPackages = changedPaths.attrdiff?.added?.length > 0
const commitsIndicateNewPackage = commitMessages.some((msg) =>
const commitsIndicateNewPackage = commitSubjects.some((msg) =>
newPackagePattern.test(msg),
)
evalLabels['8.has: package (new)'] =
Expand All @@ -347,8 +349,9 @@ module.exports = async ({ github, context, core, dry }) => {
// Label package update PRs: "packagename: X.Y.Z -> A.B.C"
// Matches versions like: 1.2.3, 0-unstable-2024-01-15, 1.3rc1, alpha, unstable
// Exclude NixOS module commits like "nixos/ncps: types.str -> types.path"
const updatePackagePattern = /(?<!nixos\/\S+): [\w.-]+ (->|→) [\w.-]+/
const commitsIndicateUpdate = commitMessages.some((msg) =>
const updatePackagePattern =
/^(?<!nixos\/)\S+: [\w.-]*\d[\w.-]* (->|→) [\w.-]*\d[\w.-]*$/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

eventially we want to do checks based on actully changed attrs of packages, but for now its good enough

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Totally. The motivation for this change was that it triggered on #474456, because of the "plfit: python -> withPython" commit. Since every valid version has a digit in it, checking for a digit fixes this particular issue.

const commitsIndicateUpdate = commitSubjects.some((msg) =>
updatePackagePattern.test(msg),
)
evalLabels['8.has: package (update)'] = commitsIndicateUpdate
Expand Down
Loading