Skip to content

Conversation

@aduh95
Copy link
Contributor

@aduh95 aduh95 commented Dec 21, 2025

The goal is to remove the need to clone the repo in https://github.com/nodejs/node/blob/main/.github/workflows/notify-on-push.yml, and instead rely on push.commits like so:

- name: Validate commits
  run: echo "$COMMITS" | npx -q core-validate-commit -
  env:
    COMMITS: ${{ toJSON(github.event.commits) }}

Copy link
Member

@JakobJingleheimer JakobJingleheimer left a comment

Choose a reason for hiding this comment

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

Thanks for handling this :)

Comment on lines +144 to +149
args.splice(0, 1, ...commits.map(commit => {
if (!commit.id || !commit.message) {
throw new Error('Each commit must have "id" and "message" properties')
}
return { sha: commit.id, ...commit }
}))
Copy link
Member

Choose a reason for hiding this comment

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

This seems a little convoluted. Could it be done with a simple loop?

Suggested change
args.splice(0, 1, ...commits.map(commit => {
if (!commit.id || !commit.message) {
throw new Error('Each commit must have "id" and "message" properties')
}
return { sha: commit.id, ...commit }
}))
for (let i = 0; i < commits.length; i++) {
if (!commit.id || !commit.message) {
throw new Error('Each commit must have "id" and "message" properties')
}
args[i] = { sha: commit.id, ...commit }
}


commitRun()
function run () {
if (parsed.tap) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: I think the else is not necessary (just return) and only creates messier nesting.

also nit: since the "is tap" block is larger, I would invert it to avoid nesting:

if (!parsed.tap) {
  v.on('commit', (c) => {
    pretty(c.commit, c.messages, v)
    commitRun()
  })

  return commitRun()
}

const tap = new Tap()
// …

const output = compiledData.trim()
tt.match(output,
/# 69435db261/,
'TAP output contains the sha of the commit being linted')
Copy link
Member

Choose a reason for hiding this comment

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

nit: not sure if the current is required by the cumbersome lint rules of this repo, but the ) not being on its own line makes this very difficult to read.

Comment on lines +310 to +312
ls.on('close', (code) => {
tt.equal(code, 1, 'CLI exits with non-zero code on error')
tt.match(errorData, /Input must be an array/, 'error message is shown')
Copy link
Member

Choose a reason for hiding this comment

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

This seems likely to create bad DX. If it's not an array, just wrap it in an array.

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.

3 participants