fix: use url.JoinPath
to join url parts
This avoids duplicated or more slashes. fixes #4759
This commit is contained in:
parent
49eeec269a
commit
46357e7856
2 changed files with 8 additions and 2 deletions
|
@ -7,6 +7,7 @@ package pull
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -56,7 +57,11 @@ func getMergeMessage(ctx context.Context, baseGitRepo *git.Repository, pr *issue
|
||||||
issueReference = "!"
|
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)
|
reviewedBy := pr.GetApprovers(ctx)
|
||||||
|
|
||||||
if mergeStyle != "" {
|
if mergeStyle != "" {
|
||||||
|
|
|
@ -47,9 +47,10 @@ func TestPullRequest_GetDefaultMergeMessage_InternalTracker(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer gitRepo.Close()
|
defer gitRepo.Close()
|
||||||
|
|
||||||
mergeMessage, _, err := GetDefaultMergeMessage(db.DefaultContext, gitRepo, pr, "")
|
mergeMessage, body, err := GetDefaultMergeMessage(db.DefaultContext, gitRepo, pr, "")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, "Merge pull request 'issue3' (#3) from branch2 into master", mergeMessage)
|
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.BaseRepoID = 1
|
||||||
pr.HeadRepoID = 2
|
pr.HeadRepoID = 2
|
||||||
|
|
Loading…
Reference in a new issue