Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Always use an empty line to separate the commit message and trailer #34512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 2, 2025

Conversation

tclin914
Copy link
Contributor

If the message from form.MergeMessageField is empty, we will miss a "\n" between the title and the "Co-authored-by:" line. The title and message should have a blank line between of them.

If the message from form.MergeMessageField is empty, we will miss a "\n"
between the title and the "Co-authored-by:" line. The title and message
should have a blank line between of them.
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 21, 2025
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label May 21, 2025
@@ -1109,8 +1109,9 @@ func MergePullRequest(ctx *context.Context) {
}

form.MergeMessageField = strings.TrimSpace(form.MergeMessageField)
message += "\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

But if form.MergeMessageField was empty, then there will be a unnecessary \n used for the empty message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We encountered a case where the commit message is empty, and the code at this line appends "\nCo-authored-by: " + sig.String(), using only one \n instead of two. As a result, there is no extra blank line between the commit title and the message body.

Would it be acceptable to always add a \n after the commit title, even if the message body is completely empty (i.e., not even the auto-appended Co-authored-by: ... line)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be acceptable to always add a \n after the commit title, even if the message body is completely empty (i.e., not even the auto-appended Co-authored-by: ... line)?

Could you design some test cases to show the expected output for each case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is the case we encountered. The commit title and Co-authored-by: line don't have an extra blank line between of them if the commit message is empty. Then it looks like from git log command
螢幕擷取畫面 2025-05-26 154352
and what we see from tig
image

I'm not familiar with gitea project. Can you guide me how can I add the testcase for my change? Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can do this: 669cccd

Then the \n can be handled correctly for all cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it's better to have a function like addCommitMessageTailer("Co-authored-by", "..."), and let it handle all cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it's better to have a function like addCommitMessageTailer("Co-authored-by", "..."), and let it handle all cases.

Try this one: 26e1f78

Copy link
Contributor

Choose a reason for hiding this comment

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

Does the new change work?

Copy link
Contributor

Choose a reason for hiding this comment

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

@tclin914 ping ~~

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks good to me. Thanks.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jun 2, 2025
@wxiaoguang wxiaoguang added this to the 1.25.0 milestone Jun 2, 2025
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jun 2, 2025
@wxiaoguang wxiaoguang added the backport/v1.24 This PR should be backported to Gitea 1.24 label Jun 2, 2025
@wxiaoguang wxiaoguang enabled auto-merge (squash) June 2, 2025 06:05
@wxiaoguang wxiaoguang changed the title Add "\n" after title unconditionally in case the message is empty Always use an empty line to separate the commit message and trailer Jun 2, 2025
@wxiaoguang wxiaoguang merged commit 82ea238 into go-gitea:main Jun 2, 2025
26 checks passed
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Jun 2, 2025
…o-gitea#34512)

If the message from form.MergeMessageField is empty, we will miss a "\n"
between the title and the "Co-authored-by:" line. The title and message
should have a blank line between of them.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Jun 2, 2025
@tclin914 tclin914 deleted the message-blank-line branch June 2, 2025 06:47
wxiaoguang added a commit that referenced this pull request Jun 2, 2025
…34512) (#34578)

Backport #34512 by tclin914

If the message from form.MergeMessageField is empty, we will miss a "\n"
between the title and the "Co-authored-by:" line. The title and message
should have a blank line between of them.

Co-authored-by: Jim Lin <jim@andestech.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
DennisRasey pushed a commit to DennisRasey/forgejo that referenced this pull request Jun 2, 2025
…railer (#8041)

This is a port of a gitea PR: go-gitea/gitea#34512.

I have added some copy-editing commits on top for cleanliness.
I haven't tested the changes manually and only relied on the existing automated test.

## Checklist
### Tests

- I added test coverage for Go changes...
  - [x] in their respective `*_test.go` for unit tests.
  - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server.

### Documentation

- [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change.
- [x] I did not document these changes and I do not expect someone else to do it.

### Release notes

- [x] I do not want this change to show in the release notes.
- [ ] I want the title to show in the release notes with a link to this pull request.
- [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title.

Co-authored-by: Jim Lin <jim@andestech.com>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8041
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Antonin Delpeuch <antonin@delpeuch.eu>
Co-committed-by: Antonin Delpeuch <antonin@delpeuch.eu>
zjjhot added a commit to zjjhot/gitea that referenced this pull request Jun 3, 2025
* giteaofficial/main:
  Refactor some tests (go-gitea#34580)
  Do not mutate incoming options to SearchRepositoryByName (go-gitea#34553)
  Fix/improve avatar sync from LDAP (go-gitea#34573)
  Fix some trivial problems (go-gitea#34579)
  Retain issue sort type when a keyword search is introduced (go-gitea#34559)
  Always use an empty line to separate the commit message and trailer (go-gitea#34512)
  Fix line-button issue after file selection in file tree (go-gitea#34574)
  [skip ci] Updated translations via Crowdin
  Fix doctor deleting orphaned issues attachments (go-gitea#34142)
  [skip ci] Updated translations via Crowdin
  Fix actions skipped commit status indicator (go-gitea#34507)
  Clean up "file-view" related styles (go-gitea#34558)
  Add "View workflow file" to Actions list page (go-gitea#34538)
  Do not mutate incoming options to RenderUserSearch and SearchUsers  (go-gitea#34544)
  Add webhook assigning test and fix possible bug (go-gitea#34420)
  Fix possible nil description of pull request when migrating from CodeCommit (go-gitea#34541)
  Refactor commit reader (go-gitea#34542)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/done All backports for this PR have been created backport/v1.24 This PR should be backported to Gitea 1.24 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.