forgejo/services/pull
Corentin 505ab87ae0 fix: allow for merge message template with empty message (#9930)
Fixes #2691

This is changing the trimming of the merge message template to allow first empty line to be considered as empty message (also referred as title in frontend). 2 unit tests were added to check for proper behavior and possible edge case (simple template with only 2 lines, not trimming needed). Also a former unit test with 3 empty lines at the beginning of the template was changed.

The behavior with this patch is:
* splitting first `\n` to separate message from body
* trim remaining `\n` from body if `\n` was present or take template as is as message (no trim necessary as no `\n` is present in the template)

As this is an old issue the expected behavior might have changed from when the issue was triaged.

I additionally manually testes on the next.forgejo.org and locally built binary from this branch, I am attaching both screenshot of final result. The test PR can be seen at [https://v13.next.forgejo.org/kajika/merge_template_issue_2691/pulls/1](https://v13.next.forgejo.org/kajika/merge_template_issue_2691/pulls/1) and, in case the next repository is deletate the content of `.forgejo/default_merge_message/MERGE_TEMPLATE.md` is (first line is empty):
```

This is the description of the merge from "${HeadBranch}" to "${BaseBranch}"
```

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9930
Reviewed-by: oliverpool <oliverpool@noreply.codeberg.org>
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Corentin <corentin@ayo.tokyo>
Co-committed-by: Corentin <corentin@ayo.tokyo>
2025-12-10 19:57:19 +01:00
..
check.go chore: move code for manual merges into merge_manual.go (#10141) 2025-11-28 07:57:31 +01:00
check_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
comment.go feat: Use receive.hideRefs (#10015) 2025-11-10 14:36:15 +01:00
commit_status.go chore: Refactor Is{Reference,Branch}Exist (#8425) 2025-07-06 07:16:43 +02:00
commit_status_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
edits.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
lfs.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
main_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
merge.go fix: allow for merge message template with empty message (#9930) 2025-12-10 19:57:19 +01:00
merge_ff_only.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
merge_manual.go chore: move code for manual merges into merge_manual.go (#10141) 2025-11-28 07:57:31 +01:00
merge_merge.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
merge_prepare.go fix: short-circuit to avoid rebasing (#8622) 2025-07-23 07:30:30 +02:00
merge_rebase.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
merge_squash.go Update module github.com/golangci/golangci-lint/v2/cmd/golangci-lint to v2.6.1 (forgejo) (#10053) 2025-11-11 07:04:35 +01:00
merge_test.go fix: allow for merge message template with empty message (#9930) 2025-12-10 19:57:19 +01:00
patch.go feat: improve checking if diffs differ (#8451) 2025-07-16 18:19:27 +02:00
patch_test.go feat: improved performances when checking for conflicts on pull requests (#7727) 2025-05-16 12:40:38 +00:00
patch_unmerged.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
pull.go feat: Use receive.hideRefs (#10015) 2025-11-10 14:36:15 +01:00
pull_test.go fix: allow for merge message template with empty message (#9930) 2025-12-10 19:57:19 +01:00
review.go fix: pull request review comment position (#9914) 2025-10-31 16:17:23 +01:00
review_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
temp_repo.go feat: bump the minimum required Git version from 2.0.0 to 2.34.1 (#8328) 2025-06-29 00:44:18 +02:00
update.go 2025-11-21 combined security patches (#10037) 2025-11-21 05:23:43 +01:00
update_rebase.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00