Merge pull request 'fix: use url.JoinPath to join url parts' (#4761) from viceice/tripple-slash-review-url into forgejo
Some checks are pending
/ release (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-remote-cacher (map[image:docker.io/valkey/valkey:7.2.5-alpine3.19 port:6379]) (push) Blocked by required conditions
testing / test-remote-cacher (map[image:ghcr.io/microsoft/garnet-alpine:1.0.14 port:6379]) (push) Blocked by required conditions
testing / test-remote-cacher (map[image:redis:7.2 port:6379]) (push) Blocked by required conditions
testing / test-remote-cacher (map[image:registry.redict.io/redict:7.3.0-scratch port:6379]) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4761
Reviewed-by: Panagiotis "Ivory" Vasilopoulos <git@n0toose.net>
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
Earl Warren 2024-07-31 14:00:32 +00:00
commit 3e28df8f67
2 changed files with 8 additions and 2 deletions

View file

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

View file

@ -47,9 +47,10 @@ func TestPullRequest_GetDefaultMergeMessage_InternalTracker(t *testing.T) {
require.NoError(t, err)
defer gitRepo.Close()
mergeMessage, _, err := GetDefaultMergeMessage(db.DefaultContext, gitRepo, pr, "")
mergeMessage, body, err := GetDefaultMergeMessage(db.DefaultContext, gitRepo, pr, "")
require.NoError(t, err)
assert.Equal(t, "Merge pull request 'issue3' (#3) from branch2 into master", mergeMessage)
assert.Equal(t, "Reviewed-on: https://try.gitea.io/user2/repo1/pulls/3\n", body)
pr.BaseRepoID = 1
pr.HeadRepoID = 2