Skip to content
Closed
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
7 changes: 6 additions & 1 deletion tools/actions/merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,19 @@ fi

git log -1 HEAD --pretty='format:%B' | git interpret-trailers --parse --no-divider | \
grep -q -x "^PR-URL: https://github.com/$OWNER/$REPOSITORY/pull/$pr$" || {
echo "Invalid PR-URL trailer"
echo "Invalid PR-URL trailer - have you run 'git node land' to add it?"
exit 1
}
git log -1 HEAD^ --pretty='format:%B' | git interpret-trailers --parse --no-divider | \
grep -q -x "^PR-URL: https://github.com/$OWNER/$REPOSITORY/pull/$pr$" && {
echo "Refuse to squash and merge a PR landing in more than one commit"
exit 1
}
git log -1 HEAD --pretty='format:%B' | git interpret-trailers --parse --no-divider | \
grep -q "^Reviewed-By: " || {
echo "No Reviewed-By: lines in the commit message - have you run 'git node land' to add them?"
exit 1
}
Comment on lines +59 to +63

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.

Really it should run core-validate-commit, there are many more things that could go wrong – maybe we can also document somewhere that humans are never ever supposed to write a PR-URL trailer manually

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.

I'm not sufficiently familiar with core-validate-commit to make that change but if it can be called from here then that would probably make more sense.

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.

I also considered adding an extra message to the error here (and on the PR-URL check) to say "Have you run 'git node land' first?" which would discourage an manual adding of the lines.

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.

Added additional message. Let me know if you're happy with the wording.

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.

I'm not sufficiently familiar with core-validate-commit to make that change

With all due respect, if you can't figure that out, you probably shouldn't be using that script at all. Folks should be landing commits using the CQ, this script was added for power users to use when the edge cases that CQ won't handle – by "power user", what I mean is someone who knows what they're doing, and are able to fix their mistakes.
I'm not sure the use case of "the user amended the commit message" is covered by the added check, the mere presence of a Reviewed-by trailer says nothing about the validity of the commit message – but also, given that tool is meant for power users, do we actually want to try to outsmart the user? FWIW on GH we only enfore the PR-URL trailer as well, so if you had git pushed (or used the GH web UI) instead of using the script, you would have come to the same result. If we want to enforce Reviewed-by, that should happen at the GH level, not in this script IMO (and I'm not sure we need to enforce it, because it might have been the first time it has happened since we added the GH rule enforcing that PR-URL trailer is present)

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.

With all due respect, if you can't figure that out, you probably shouldn't be using that script at all.

My statement was more about the fact I hadn't looked at it before rather than not being able to figure it out.

While it would certainly be possible to include that I'm not sure we'd want to add a dependency on that into the script though since I don't think it currently has any other dependency on node itself currently.

But if you don't think this additional check and notice is appropriate for any use case I'll close the PR.

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.

since I don't think it currently has any other dependency on node itself currently.

It doesn't have a dependency on node AFAICT, the dependencies are listed in

# Requires [gh](https://cli.github.com/), [jq](https://jqlang.github.io), git, and grep. Also awk if you pass a URL.

I'm not sure we'd want to add a dependency on that into the script

Definitely agree on that, adding deps should not be done lightly.

But if you don't think this additional check and notice is appropriate for any use case

My point is that if we're adding a check, it shouldn't go on merge.sh – it should be set as a rule on GH so it covers git push and folks using the web UI.

I'll close the PR

Well I would still land the wording change reminding the user if they ran git node land


commit_title=$(git log -1 --pretty='format:%s')
commit_body=$(git log -1 --pretty='format:%b')
Expand Down