fix: correct Reviewed-on URL in merge message for subpath deployments (#11240)

Fixes: #11238

### 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.
- I added test coverage for JavaScript changes...
  - [ ] in `web_src/js/*.test.js` if it can be unit tested.
  - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)).

### 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] This change will be noticed by a Forgejo user or admin (feature, bug fix, performance, etc.). I suggest to include a release note for this change.
- [ ] This change is not visible to a Forgejo user or admin (refactor, dependency upgrade, etc.). I think there is no need to add a release note for this change.

*The decision if the pull request will be shown in the release notes is up to the mergers / release team.*

The content of the `release-notes/<pull request number>.md` file will serve as the basis for the release notes. If the file does not exist, the title of the pull request will be used instead.

Co-authored-by: Diego Díez <diegodiez.ddr@gmail.com>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/11240
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
Co-authored-by: Robert Wolff <mahlzahn@posteo.de>
Co-committed-by: Robert Wolff <mahlzahn@posteo.de>
This commit is contained in:
Robert Wolff 2026-02-11 18:12:29 +01:00 committed by Mathieu Fenniak
parent c01404a373
commit 7791984040
2 changed files with 8 additions and 6 deletions

View file

@ -7,7 +7,6 @@ package pull
import (
"context"
"fmt"
"net/url"
"os"
"path/filepath"
"regexp"
@ -80,11 +79,7 @@ func getMergeMessage(ctx context.Context, baseGitRepo *git.Repository, pr *issue
issueReference = "!"
}
issueURL, err := url.JoinPath(setting.AppURL, pr.Issue.Link())
if err != nil {
return "", "", err
}
reviewedOn := fmt.Sprintf("Reviewed-on: %s", issueURL)
reviewedOn := fmt.Sprintf("Reviewed-on: %s", pr.Issue.HTMLURL())
reviewedBy := pr.GetApprovers(ctx)
body = fmt.Sprintf("%s\n%s", reviewedOn, reviewedBy)

View file

@ -14,6 +14,7 @@ import (
"forgejo.org/models/unittest"
"forgejo.org/modules/git"
"forgejo.org/modules/gitrepo"
"forgejo.org/modules/setting"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -57,6 +58,12 @@ func TestPullRequest_GetDefaultMergeMessage_InternalTracker(t *testing.T) {
mergeMessage, _, err = GetDefaultMergeMessage(db.DefaultContext, gitRepo, pr, "")
require.NoError(t, err)
assert.Equal(t, "Merge pull request 'issue3' (#3) from user2/repo1:branch2 into master", mergeMessage)
setting.AppURL = "https://example.org/suburl/"
setting.AppSubURL = "/suburl"
_, body, err = GetDefaultMergeMessage(db.DefaultContext, gitRepo, pr, "")
require.NoError(t, err)
assert.Equal(t, "Reviewed-on: https://example.org/suburl/user2/repo1/pulls/3\n", body)
}
func TestPullRequest_GetDefaultMergeMessage_ExternalTracker(t *testing.T) {