Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion services/webhook/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package webhook

import (
"context"
"strings"

git_model "code.gitea.io/gitea/models/git"
issues_model "code.gitea.io/gitea/models/issues"
Expand Down Expand Up @@ -871,14 +872,22 @@ func (m *webhookNotifier) CreateCommitStatus(ctx context.Context, repo *repo_mod
return
}

// as a webhook url, target should be an absolute url. But for internal actions target url
// the target url is a url path with no host and port to make it easy to be visited
// from multiple hosts. So we need to convert it to an absolute url here.
target := status.TargetURL
if strings.HasPrefix(target, "/") {
target = setting.AppURL + strings.TrimPrefix(target, "/")
}

payload := api.CommitStatusPayload{
Context: status.Context,
CreatedAt: status.CreatedUnix.AsTime().UTC(),
Description: status.Description,
ID: status.ID,
SHA: commit.Sha1,
State: status.State.String(),
TargetURL: status.TargetURL,
TargetURL: target,

Commit: apiCommit,
Repo: convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm.AccessModeOwner}),
Expand Down
Loading