[
https://issues.apache.org/jira/browse/KAFKA-21579?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Chang updated KAFKA-21579:
-------------------------------
Description:
The PR description becomes the commit message when a PR is merged. Two scripts
edit it automatically:
* {{.github/scripts/pr-format.py}} (PR Linter) re-wraps the whole description
to 72 characters and writes it back.
* {{.github/scripts/pr-reviewers-trailer.py}} adds reviewers to the
{{Reviewers:}} trailer.
We want four things at the same time:
* The author's text stays as the author wrote it.
* Commit messages are tidy, with lines of at most 72 characters.
* Reviewer credit is reliable. For this, {{Reviewers:}} must be a valid git
trailer.
* Committers do not have to type the reviewers by hand.
Today the tools give up the first one to get the second one. To re-wrap the
text, {{pr-format.py}} has to guess its structure. When the guess is wrong, the
description is damaged:
* Adjacent trailers are joined into one line. This is the case that was first
reported here:
{code}
Co-Authored-By: Some Bot <[email protected]>
Reviewers: Ken Huang <[email protected]>, Federico Valeri
<[email protected]>{code}
becomes
{code}
Co-Authored-By: Some Bot <[email protected]> Reviewers: Ken
Huang <[email protected]>, Federico Valeri <[email protected]>{code}
{{Reviewers:}} is now part of the {{Co-Authored-By:}} value. The next review
adds a second {{Reviewers:}} trailer.
* The rows of a Markdown table are joined into one paragraph.
Each new case needs one more special rule in the formatter. Lists, code blocks
and backticks already have one.
This trade is based on an assumption that is not true today. The re-wrap was
added in KAFKA-19013 with this reason: PRs will be merged with the merge queue,
GitHub wraps the commit message there, and the committer cannot edit it. So the
tool must wrap the text first.
Both parts of that reason do not hold:
* The merge queue is not in use on {{apache/kafka}}. The rulesets have no
{{merge_queue}} rule, the GraphQL field {{mergeQueue(branch: "trunk")}} is
null, and no workflow has a {{merge_group}} trigger.
* In tests on a fork, GitHub wraps long lines and converts CRLF to LF by
itself when it builds the default squash commit message from the PR
description. This was checked with the API and in the merge dialog of the web
page. It does not join short lines and it does not change code blocks.
So we can keep the author's text and still get tidy commit messages. One gap is
left. GitHub does not indent the lines that it wraps, and a wrapped
{{Reviewers:}} trailer without indentation is cut short. So a long
{{Reviewers:}} trailer is the only text that a tool still has to fold.
Proposed change:
# {{pr-format.py}} only reads the PR. It checks the title and the description
and reports the result. It never edits the description.
# {{pr-reviewers-trailer.py}} is the only script that edits the description.
It changes only the {{Reviewers:}} trailer in the last paragraph and keeps all
other text byte for byte.
# {{pr-reviewers-trailer.py}} folds a {{Reviewers:}} trailer that is longer
than 72 characters. It breaks the line only after a comma, and each
continuation line starts with a space, so git still reads one trailer.
# If the last paragraph has more than one {{Reviewers:}} trailer,
{{pr-reviewers-trailer.py}} joins them into one. It keeps every name as written
and keeps the order. A name that is written twice is kept once.
# {{pr-reviewers-trailer.py}} also runs when the description is edited. It
adds nobody then. It only joins and folds the existing {{Reviewers:}} trailers.
So a committer can add reviewers by hand, on one long line or on a new
{{Reviewers:}} line, and the tool takes care of the rest.
# If the author writes text below the {{Reviewers:}} trailer, git no longer
reads it as a trailer, and today the earlier reviewers lose their credit
without any warning. {{pr-format.py}} now fails with a message that says how to
fix it, and {{pr-reviewers-trailer.py}} does not edit the description until it
is fixed.
# Add unit tests for both scripts, and a workflow that runs them when the
scripts change.
The rule for people is short: write {{Reviewers:}} in the last paragraph with
the names separated by commas, and write nothing below it. The tool owns the
line breaks of this trailer. People own the names. Other trailers, such as
{{Co-Authored-By:}}, stay as the author wrote them, one per line.
What this costs:
* The author cannot write text below the {{Reviewers:}} trailer. The PR Linter
fails until the text is moved above it.
* The tools do not fold other trailers. If another trailer in the last
paragraph is longer than 72 characters, GitHub wraps it without indentation
when it builds the default commit message. git then reads no trailer in that
paragraph, and the {{Reviewers:}} trailer is lost with it. The old formatter
did not indent these lines either.
* If a committer edits the commit message in the merge dialog, GitHub does not
wrap it, and the tools do not run. Long lines from the description then stay
long in the commit, and a reviewer added there is not checked.
* A line that starts with {{Reviewers:}} inside a code block makes the new
check fail.
* The tool needs about 20 seconds after an edit of the description. If a
committer adds a long {{Reviewers:}} line and merges before the tool has folded
it, GitHub wraps the line without indentation and the trailers are lost.
* GitHub also wraps a Markdown table row that is longer than 72 characters.
The table is then broken in the commit message. The table in the PR is not
changed.
was:
The PR description becomes the commit message when a PR is merged. Two scripts
edit it automatically:
* {{.github/scripts/pr-format.py}} (PR Linter) re-wraps the whole description
to 72 characters and writes it back.
* {{.github/scripts/pr-reviewers-trailer.py}} adds reviewers to the
{{Reviewers:}} trailer.
We want four things at the same time:
* The author's text stays as the author wrote it.
* Commit messages are tidy, with lines of at most 72 characters.
* Reviewer credit is reliable. For this, {{Reviewers:}} must be a valid git
trailer.
* Committers do not have to type the reviewers by hand.
Today the tools give up the first one to get the second one. To re-wrap the
text, {{pr-format.py}} has to guess its structure. When the guess is wrong, the
description is damaged:
* Adjacent trailers are joined into one line. This is the case that was first
reported here:
{code}
Co-Authored-By: Some Bot <[email protected]>
Reviewers: Ken Huang <[email protected]>, Federico Valeri
<[email protected]>{code}
becomes
{code}
Co-Authored-By: Some Bot <[email protected]> Reviewers: Ken
Huang <[email protected]>, Federico Valeri <[email protected]>{code}
{{Reviewers:}} is now part of the {{Co-Authored-By:}} value. The next review
adds a second {{Reviewers:}} trailer.
* The rows of a Markdown table are joined into one paragraph.
Each new case needs one more special rule in the formatter. Lists, code blocks
and backticks already have one.
This trade is based on an assumption that is not true today. The re-wrap was
added in KAFKA-19013 with this reason: PRs will be merged with the merge queue,
GitHub wraps the commit message there, and the committer cannot edit it. So the
tool must wrap the text first.
Both parts of that reason do not hold:
* The merge queue is not in use on {{apache/kafka}}. The rulesets have no
{{merge_queue}} rule, the GraphQL field {{mergeQueue(branch: "trunk")}} is
null, and no workflow has a {{merge_group}} trigger.
* In tests on a fork, GitHub wraps long lines and converts CRLF to LF by
itself when it builds the default squash commit message from the PR
description. This was checked with the API and in the merge dialog of the web
page. It does not join short lines and it does not change code blocks.
So we can keep the author's text and still get tidy commit messages. One gap is
left. GitHub does not indent the lines that it wraps, and a wrapped
{{Reviewers:}} trailer without indentation is cut short. So a long
{{Reviewers:}} trailer is the only text that a tool still has to fold.
Proposed change:
# {{pr-format.py}} only reads the PR. It checks the title and the description
and reports the result. It never edits the description.
# {{pr-reviewers-trailer.py}} is the only script that edits the description.
It changes only the {{Reviewers:}} trailer in the last paragraph and keeps all
other text byte for byte.
# {{pr-reviewers-trailer.py}} folds a {{Reviewers:}} trailer that is longer
than 72 characters. It breaks the line only after a comma, and each
continuation line starts with a space, so git still reads one trailer.
# If the last paragraph has more than one {{Reviewers:}} trailer,
{{pr-reviewers-trailer.py}} joins them into one. It keeps every name as written
and keeps the order. A name that is written twice is kept once.
# {{pr-reviewers-trailer.py}} also runs when the description is edited. It
adds nobody then. It only joins and folds the existing {{Reviewers:}} trailers.
So a committer can add reviewers by hand, on one long line or on a new
{{Reviewers:}} line, and the tool takes care of the rest.
# If the author writes text below the {{Reviewers:}} trailer, git no longer
reads it as a trailer, and today the earlier reviewers lose their credit
without any warning. {{pr-format.py}} now fails with a message that says how to
fix it, and {{pr-reviewers-trailer.py}} does not edit the description until it
is fixed.
# Add unit tests for both scripts, and a workflow that runs them when the
scripts change.
The rule for people is short: write {{Reviewers:}} in the last paragraph with
the names separated by commas, and write nothing below it. The tool owns the
line breaks of this trailer. People own the names. Other trailers, such as
{{Co-Authored-By:}}, stay as the author wrote them, one per line.
What this costs:
* The author cannot write text below the {{Reviewers:}} trailer. The PR Linter
fails until the text is moved above it.
* The tools do not fold other trailers. If another trailer in the last
paragraph is longer than 72 characters, GitHub wraps it without indentation
when it builds the default commit message. git then reads no trailer in that
paragraph, and the {{Reviewers:}} trailer is lost with it. The old formatter
did not indent these lines either.
* If a committer edits the commit message in the merge dialog, GitHub does not
wrap it, and the tools do not run. Long lines from the description then stay
long in the commit, and a reviewer added there is not checked.
* A line that starts with {{Reviewers:}} inside a code block makes the new
check fail.
* The tool needs about 20 seconds after an edit of the description. If a
committer adds a long {{Reviewers:}} line and merges before the tool has folded
it, GitHub wraps the line without indentation and the trailers are lost.
* GitHub also wraps a Markdown table row that is longer than 72 characters.
The table is then broken in the commit message. The table in the PR is not
changed.
Not in scope:
* A marker or separator line in the description. It would be copied into every
commit message.
> PR tools should not rewrite the PR description written by the author
> --------------------------------------------------------------------
>
> Key: KAFKA-21579
> URL: https://issues.apache.org/jira/browse/KAFKA-21579
> Project: Kafka
> Issue Type: Bug
> Reporter: Ken Huang
> Assignee: Eric Chang
> Priority: Minor
>
> The PR description becomes the commit message when a PR is merged. Two
> scripts edit it automatically:
> * {{.github/scripts/pr-format.py}} (PR Linter) re-wraps the whole
> description to 72 characters and writes it back.
> * {{.github/scripts/pr-reviewers-trailer.py}} adds reviewers to the
> {{Reviewers:}} trailer.
> We want four things at the same time:
> * The author's text stays as the author wrote it.
> * Commit messages are tidy, with lines of at most 72 characters.
> * Reviewer credit is reliable. For this, {{Reviewers:}} must be a valid git
> trailer.
> * Committers do not have to type the reviewers by hand.
> Today the tools give up the first one to get the second one. To re-wrap the
> text, {{pr-format.py}} has to guess its structure. When the guess is wrong,
> the description is damaged:
> * Adjacent trailers are joined into one line. This is the case that was
> first reported here:
> {code}
> Co-Authored-By: Some Bot <[email protected]>
> Reviewers: Ken Huang <[email protected]>, Federico Valeri
> <[email protected]>{code}
> becomes
> {code}
> Co-Authored-By: Some Bot <[email protected]> Reviewers: Ken
> Huang <[email protected]>, Federico Valeri <[email protected]>{code}
> {{Reviewers:}} is now part of the {{Co-Authored-By:}} value. The next review
> adds a second {{Reviewers:}} trailer.
> * The rows of a Markdown table are joined into one paragraph.
> Each new case needs one more special rule in the formatter. Lists, code
> blocks and backticks already have one.
> This trade is based on an assumption that is not true today. The re-wrap was
> added in KAFKA-19013 with this reason: PRs will be merged with the merge
> queue, GitHub wraps the commit message there, and the committer cannot edit
> it. So the tool must wrap the text first.
> Both parts of that reason do not hold:
> * The merge queue is not in use on {{apache/kafka}}. The rulesets have no
> {{merge_queue}} rule, the GraphQL field {{mergeQueue(branch: "trunk")}} is
> null, and no workflow has a {{merge_group}} trigger.
> * In tests on a fork, GitHub wraps long lines and converts CRLF to LF by
> itself when it builds the default squash commit message from the PR
> description. This was checked with the API and in the merge dialog of the web
> page. It does not join short lines and it does not change code blocks.
> So we can keep the author's text and still get tidy commit messages. One gap
> is left. GitHub does not indent the lines that it wraps, and a wrapped
> {{Reviewers:}} trailer without indentation is cut short. So a long
> {{Reviewers:}} trailer is the only text that a tool still has to fold.
> Proposed change:
> # {{pr-format.py}} only reads the PR. It checks the title and the
> description and reports the result. It never edits the description.
> # {{pr-reviewers-trailer.py}} is the only script that edits the description.
> It changes only the {{Reviewers:}} trailer in the last paragraph and keeps
> all other text byte for byte.
> # {{pr-reviewers-trailer.py}} folds a {{Reviewers:}} trailer that is longer
> than 72 characters. It breaks the line only after a comma, and each
> continuation line starts with a space, so git still reads one trailer.
> # If the last paragraph has more than one {{Reviewers:}} trailer,
> {{pr-reviewers-trailer.py}} joins them into one. It keeps every name as
> written and keeps the order. A name that is written twice is kept once.
> # {{pr-reviewers-trailer.py}} also runs when the description is edited. It
> adds nobody then. It only joins and folds the existing {{Reviewers:}}
> trailers. So a committer can add reviewers by hand, on one long line or on a
> new {{Reviewers:}} line, and the tool takes care of the rest.
> # If the author writes text below the {{Reviewers:}} trailer, git no longer
> reads it as a trailer, and today the earlier reviewers lose their credit
> without any warning. {{pr-format.py}} now fails with a message that says how
> to fix it, and {{pr-reviewers-trailer.py}} does not edit the description
> until it is fixed.
> # Add unit tests for both scripts, and a workflow that runs them when the
> scripts change.
> The rule for people is short: write {{Reviewers:}} in the last paragraph with
> the names separated by commas, and write nothing below it. The tool owns the
> line breaks of this trailer. People own the names. Other trailers, such as
> {{Co-Authored-By:}}, stay as the author wrote them, one per line.
> What this costs:
> * The author cannot write text below the {{Reviewers:}} trailer. The PR
> Linter fails until the text is moved above it.
> * The tools do not fold other trailers. If another trailer in the last
> paragraph is longer than 72 characters, GitHub wraps it without indentation
> when it builds the default commit message. git then reads no trailer in that
> paragraph, and the {{Reviewers:}} trailer is lost with it. The old formatter
> did not indent these lines either.
> * If a committer edits the commit message in the merge dialog, GitHub does
> not wrap it, and the tools do not run. Long lines from the description then
> stay long in the commit, and a reviewer added there is not checked.
> * A line that starts with {{Reviewers:}} inside a code block makes the new
> check fail.
> * The tool needs about 20 seconds after an edit of the description. If a
> committer adds a long {{Reviewers:}} line and merges before the tool has
> folded it, GitHub wraps the line without indentation and the trailers are
> lost.
> * GitHub also wraps a Markdown table row that is longer than 72 characters.
> The table is then broken in the commit message. The table in the PR is not
> changed.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)