loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix compatible for webhook ref type (#25195)

Fix #25185
Caused by #24634

authored by

Lunny Xiao and committed by
GitHub
419804fd 2126f712

+21 -7
+14
modules/git/ref.go
··· 163 163 } 164 164 165 165 // RefGroup returns the group type of the reference 166 + // Using the name of the directory under .git/refs 166 167 func (ref RefName) RefGroup() string { 167 168 if ref.IsBranch() { 168 169 return "heads" ··· 180 181 return "for" 181 182 } 182 183 return "" 184 + } 185 + 186 + // RefType returns the simple ref type of the reference, e.g. branch, tag 187 + // It's differrent from RefGroup, which is using the name of the directory under .git/refs 188 + // Here we using branch but not heads, using tag but not tags 189 + func (ref RefName) RefType() string { 190 + var refType string 191 + if ref.IsBranch() { 192 + refType = "branch" 193 + } else if ref.IsTag() { 194 + refType = "tag" 195 + } 196 + return refType 183 197 } 184 198 185 199 // RefURL returns the absolute URL for a ref in a repository
+2 -2
routers/api/actions/runner/utils.go
··· 98 98 baseRef = pullPayload.PullRequest.Base.Ref 99 99 headRef = pullPayload.PullRequest.Head.Ref 100 100 } 101 + 101 102 refName := git.RefName(t.Job.Run.Ref) 102 - refType := refName.RefGroup() 103 103 104 104 taskContext, err := structpb.NewStruct(map[string]interface{}{ 105 105 // standard contexts, see https://docs.github.com/en/actions/learn-github-actions/contexts#github-context ··· 121 121 "ref": t.Job.Run.Ref, // string, The fully-formed ref of the branch or tag that triggered the workflow run. For workflows triggered by push, this is the branch or tag ref that was pushed. For workflows triggered by pull_request, this is the pull request merge branch. For workflows triggered by release, this is the release tag created. For other triggers, this is the branch or tag ref that triggered the workflow run. This is only set if a branch or tag is available for the event type. The ref given is fully-formed, meaning that for branches the format is refs/heads/<branch_name>, for pull requests it is refs/pull/<pr_number>/merge, and for tags it is refs/tags/<tag_name>. For example, refs/heads/feature-branch-1. 122 122 "ref_name": refName.String(), // string, The short ref name of the branch or tag that triggered the workflow run. This value matches the branch or tag name shown on GitHub. For example, feature-branch-1. 123 123 "ref_protected": false, // boolean, true if branch protections are configured for the ref that triggered the workflow run. 124 - "ref_type": refType, // string, The type of ref that triggered the workflow run. Valid values are branch or tag. 124 + "ref_type": refName.RefType(), // string, The type of ref that triggered the workflow run. Valid values are branch or tag. 125 125 "path": "", // string, Path on the runner to the file that sets system PATH variables from workflow commands. This file is unique to the current step and is a different file for each step in a job. For more information, see "Workflow commands for GitHub Actions." 126 126 "repository": t.Job.Run.Repo.OwnerName + "/" + t.Job.Run.Repo.Name, // string, The owner and repository name. For example, Codertocat/Hello-World. 127 127 "repository_owner": t.Job.Run.Repo.OwnerName, // string, The repository owner's name. For example, Codertocat.
+2 -2
services/actions/notifier.go
··· 384 384 WithPayload(&api.CreatePayload{ 385 385 Ref: refFullName.ShortName(), 386 386 Sha: refID, 387 - RefType: refFullName.RefGroup(), 387 + RefType: refFullName.RefType(), 388 388 Repo: apiRepo, 389 389 Sender: apiPusher, 390 390 }). ··· 401 401 WithRef(refFullName.ShortName()). // FIXME: should we use a full ref name 402 402 WithPayload(&api.DeletePayload{ 403 403 Ref: refFullName.ShortName(), 404 - RefType: refFullName.RefGroup(), 404 + RefType: refFullName.RefType(), 405 405 PusherType: api.PusherTypeUser, 406 406 Repo: apiRepo, 407 407 Sender: apiPusher,
+3 -3
services/webhook/notifier.go
··· 755 755 if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventCreate, &api.CreatePayload{ 756 756 Ref: refName, // FIXME: should it be a full ref name? 757 757 Sha: refID, 758 - RefType: refFullName.RefGroup(), 758 + RefType: refFullName.RefType(), 759 759 Repo: apiRepo, 760 760 Sender: apiPusher, 761 761 }); err != nil { ··· 791 791 792 792 if err := PrepareWebhooks(ctx, EventSource{Repository: repo}, webhook_module.HookEventDelete, &api.DeletePayload{ 793 793 Ref: refName, // FIXME: should it be a full ref name? 794 - RefType: refFullName.RefGroup(), 794 + RefType: refFullName.RefType(), 795 795 PusherType: api.PusherTypeUser, 796 796 Repo: apiRepo, 797 797 Sender: apiPusher, 798 798 }); err != nil { 799 - log.Error("PrepareWebhooks.(delete %s): %v", refFullName.RefGroup(), err) 799 + log.Error("PrepareWebhooks.(delete %s): %v", refFullName.RefType(), err) 800 800 } 801 801 } 802 802