diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2025-01-13 14:01:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-13 14:01:53 +0800 |
commit | 2ea929a9527b403ec72b0ed656a526f818525ad6 (patch) | |
tree | ed3da807f2889f855ec45a3a36812d013696acb6 /services/webhook | |
parent | 81352542fd29d1809bd483dec60849ec39d84388 (diff) | |
download | gitea-2ea929a9527b403ec72b0ed656a526f818525ad6.tar.gz gitea-2ea929a9527b403ec72b0ed656a526f818525ad6.zip |
Refactor RefName (#33234)
And fix some FIXMEs
Diffstat (limited to 'services/webhook')
-rw-r--r-- | services/webhook/notifier.go | 12 | ||||
-rw-r--r-- | services/webhook/slack.go | 6 |
2 files changed, 7 insertions, 11 deletions
diff --git a/services/webhook/notifier.go b/services/webhook/notifier.go index a3d5cb34b1..2fce4b351e 100644 --- a/services/webhook/notifier.go +++ b/services/webhook/notifier.go @@ -763,12 +763,10 @@ func (m *webhookNotifier) PullRequestReviewRequest(ctx context.Context, doer *us func (m *webhookNotifier) CreateRef(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, refFullName git.RefName, refID string) { apiPusher := convert.ToUser(ctx, pusher, nil) apiRepo := convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm.AccessModeNone}) - refName := refFullName.ShortName() - if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventCreate, &api.CreatePayload{ - Ref: refName, // FIXME: should it be a full ref name? + Ref: refFullName.ShortName(), // FIXME: should it be a full ref name? But it will break the existing webhooks? Sha: refID, - RefType: refFullName.RefType(), + RefType: string(refFullName.RefType()), Repo: apiRepo, Sender: apiPusher, }); err != nil { @@ -800,11 +798,9 @@ func (m *webhookNotifier) PullRequestSynchronized(ctx context.Context, doer *use func (m *webhookNotifier) DeleteRef(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, refFullName git.RefName) { apiPusher := convert.ToUser(ctx, pusher, nil) apiRepo := convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm.AccessModeOwner}) - refName := refFullName.ShortName() - if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventDelete, &api.DeletePayload{ - Ref: refName, // FIXME: should it be a full ref name? - RefType: refFullName.RefType(), + Ref: refFullName.ShortName(), // FIXME: should it be a full ref name? But it will break the existing webhooks? + RefType: string(refFullName.RefType()), PusherType: api.PusherTypeUser, Repo: apiRepo, Sender: apiPusher, diff --git a/services/webhook/slack.go b/services/webhook/slack.go index c905e7a89f..2a49df2453 100644 --- a/services/webhook/slack.go +++ b/services/webhook/slack.go @@ -84,9 +84,9 @@ func SlackLinkFormatter(url, text string) string { // SlackLinkToRef slack-formatter link to a repo ref func SlackLinkToRef(repoURL, ref string) string { // FIXME: SHA1 hardcoded here - url := git.RefURL(repoURL, ref) - refName := git.RefName(ref).ShortName() - return SlackLinkFormatter(url, refName) + refName := git.RefName(ref) + url := repoURL + "/src/" + refName.RefWebLinkPath() + return SlackLinkFormatter(url, refName.ShortName()) } // Create implements payloadConvertor Create method |