Fix spelling of HookProcReceiveResult (#16690)

tokarchuk/v1.17
Lunny Xiao 3 years ago committed by GitHub
parent bbf9f41354
commit 74d75eb69c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      modules/private/hook.go
  2. 2
      routers/private/hook.go
  3. 18
      services/agit/agit.go

@ -81,14 +81,14 @@ type HookPostReceiveBranchResult struct {
URL string URL string
} }
// HockProcReceiveResult represents an individual result from ProcReceive // HookProcReceiveResult represents an individual result from ProcReceive
type HockProcReceiveResult struct { type HookProcReceiveResult struct {
Results []HockProcReceiveRefResult Results []HookProcReceiveRefResult
Err string Err string
} }
// HockProcReceiveRefResult represents an individual result from ProcReceive // HookProcReceiveRefResult represents an individual result from ProcReceive
type HockProcReceiveRefResult struct { type HookProcReceiveRefResult struct {
OldOID string OldOID string
NewOID string NewOID string
Ref string Ref string
@ -150,7 +150,7 @@ func HookPostReceive(ctx context.Context, ownerName, repoName string, opts HookO
} }
// HookProcReceive proc-receive hook // HookProcReceive proc-receive hook
func HookProcReceive(ctx context.Context, ownerName, repoName string, opts HookOptions) (*HockProcReceiveResult, error) { func HookProcReceive(ctx context.Context, ownerName, repoName string, opts HookOptions) (*HookProcReceiveResult, error) {
reqURL := setting.LocalURL + fmt.Sprintf("api/internal/hook/proc-receive/%s/%s", reqURL := setting.LocalURL + fmt.Sprintf("api/internal/hook/proc-receive/%s/%s",
url.PathEscape(ownerName), url.PathEscape(ownerName),
url.PathEscape(repoName), url.PathEscape(repoName),
@ -170,7 +170,7 @@ func HookProcReceive(ctx context.Context, ownerName, repoName string, opts HookO
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
return nil, errors.New(decodeJSONError(resp).Err) return nil, errors.New(decodeJSONError(resp).Err)
} }
res := &HockProcReceiveResult{} res := &HookProcReceiveResult{}
_ = json.NewDecoder(resp.Body).Decode(res) _ = json.NewDecoder(resp.Body).Decode(res)
return res, nil return res, nil

@ -668,7 +668,7 @@ func HookProcReceive(ctx *gitea_context.PrivateContext) {
return return
} }
ctx.JSON(http.StatusOK, private.HockProcReceiveResult{ ctx.JSON(http.StatusOK, private.HookProcReceiveResult{
Results: results, Results: results,
}) })
} }

@ -20,7 +20,7 @@ import (
) )
// ProcRecive handle proc receive work // ProcRecive handle proc receive work
func ProcRecive(ctx *context.PrivateContext, opts *private.HookOptions) []private.HockProcReceiveRefResult { func ProcRecive(ctx *context.PrivateContext, opts *private.HookOptions) []private.HookProcReceiveRefResult {
// TODO: Add more options? // TODO: Add more options?
var ( var (
topicBranch string topicBranch string
@ -29,7 +29,7 @@ func ProcRecive(ctx *context.PrivateContext, opts *private.HookOptions) []privat
forcePush bool forcePush bool
) )
results := make([]private.HockProcReceiveRefResult, 0, len(opts.OldCommitIDs)) results := make([]private.HookProcReceiveRefResult, 0, len(opts.OldCommitIDs))
repo := ctx.Repo.Repository repo := ctx.Repo.Repository
gitRepo := ctx.Repo.GitRepo gitRepo := ctx.Repo.GitRepo
ownerName := ctx.Repo.Repository.OwnerName ownerName := ctx.Repo.Repository.OwnerName
@ -40,7 +40,7 @@ func ProcRecive(ctx *context.PrivateContext, opts *private.HookOptions) []privat
for i := range opts.OldCommitIDs { for i := range opts.OldCommitIDs {
if opts.NewCommitIDs[i] == git.EmptySHA { if opts.NewCommitIDs[i] == git.EmptySHA {
results = append(results, private.HockProcReceiveRefResult{ results = append(results, private.HookProcReceiveRefResult{
OriginalRef: opts.RefFullNames[i], OriginalRef: opts.RefFullNames[i],
OldOID: opts.OldCommitIDs[i], OldOID: opts.OldCommitIDs[i],
NewOID: opts.NewCommitIDs[i], NewOID: opts.NewCommitIDs[i],
@ -50,7 +50,7 @@ func ProcRecive(ctx *context.PrivateContext, opts *private.HookOptions) []privat
} }
if !strings.HasPrefix(opts.RefFullNames[i], git.PullRequestPrefix) { if !strings.HasPrefix(opts.RefFullNames[i], git.PullRequestPrefix) {
results = append(results, private.HockProcReceiveRefResult{ results = append(results, private.HookProcReceiveRefResult{
IsNotMatched: true, IsNotMatched: true,
OriginalRef: opts.RefFullNames[i], OriginalRef: opts.RefFullNames[i],
}) })
@ -71,7 +71,7 @@ func ProcRecive(ctx *context.PrivateContext, opts *private.HookOptions) []privat
} }
if len(topicBranch) == 0 && len(curentTopicBranch) == 0 { if len(topicBranch) == 0 && len(curentTopicBranch) == 0 {
results = append(results, private.HockProcReceiveRefResult{ results = append(results, private.HookProcReceiveRefResult{
OriginalRef: opts.RefFullNames[i], OriginalRef: opts.RefFullNames[i],
OldOID: opts.OldCommitIDs[i], OldOID: opts.OldCommitIDs[i],
NewOID: opts.NewCommitIDs[i], NewOID: opts.NewCommitIDs[i],
@ -166,7 +166,7 @@ func ProcRecive(ctx *context.PrivateContext, opts *private.HookOptions) []privat
log.Trace("Pull request created: %d/%d", repo.ID, prIssue.ID) log.Trace("Pull request created: %d/%d", repo.ID, prIssue.ID)
results = append(results, private.HockProcReceiveRefResult{ results = append(results, private.HookProcReceiveRefResult{
Ref: pr.GetGitRefName(), Ref: pr.GetGitRefName(),
OriginalRef: opts.RefFullNames[i], OriginalRef: opts.RefFullNames[i],
OldOID: git.EmptySHA, OldOID: git.EmptySHA,
@ -194,7 +194,7 @@ func ProcRecive(ctx *context.PrivateContext, opts *private.HookOptions) []privat
} }
if oldCommitID == opts.NewCommitIDs[i] { if oldCommitID == opts.NewCommitIDs[i] {
results = append(results, private.HockProcReceiveRefResult{ results = append(results, private.HookProcReceiveRefResult{
OriginalRef: opts.RefFullNames[i], OriginalRef: opts.RefFullNames[i],
OldOID: opts.OldCommitIDs[i], OldOID: opts.OldCommitIDs[i],
NewOID: opts.NewCommitIDs[i], NewOID: opts.NewCommitIDs[i],
@ -212,7 +212,7 @@ func ProcRecive(ctx *context.PrivateContext, opts *private.HookOptions) []privat
}) })
return nil return nil
} else if len(output) > 0 { } else if len(output) > 0 {
results = append(results, private.HockProcReceiveRefResult{ results = append(results, private.HookProcReceiveRefResult{
OriginalRef: oldCommitID, OriginalRef: oldCommitID,
OldOID: opts.OldCommitIDs[i], OldOID: opts.OldCommitIDs[i],
NewOID: opts.NewCommitIDs[i], NewOID: opts.NewCommitIDs[i],
@ -255,7 +255,7 @@ func ProcRecive(ctx *context.PrivateContext, opts *private.HookOptions) []privat
notification.NotifyPullRequestSynchronized(pusher, pr) notification.NotifyPullRequestSynchronized(pusher, pr)
isForcePush := comment != nil && comment.IsForcePush isForcePush := comment != nil && comment.IsForcePush
results = append(results, private.HockProcReceiveRefResult{ results = append(results, private.HookProcReceiveRefResult{
OldOID: oldCommitID, OldOID: oldCommitID,
NewOID: opts.NewCommitIDs[i], NewOID: opts.NewCommitIDs[i],
Ref: pr.GetGitRefName(), Ref: pr.GetGitRefName(),

Loading…
Cancel
Save