From 2877ffa2539608595859c0e94bf365cc9e94ed90 Mon Sep 17 00:00:00 2001 From: Abhinav Singh Date: Wed, 20 Dec 2023 14:58:29 +0530 Subject: [PATCH] fix: ref should be branch name for harness code (#288) * fix: ref should be branch name for harness code * fix: add uid for harness webhook --- scm/driver/harness/repo.go | 2 ++ scm/driver/harness/testdata/webhooks/branch_create.json.golden | 2 +- scm/driver/harness/testdata/webhooks/branch_updated.json.golden | 2 +- scm/driver/harness/webhook.go | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scm/driver/harness/repo.go b/scm/driver/harness/repo.go index da423755..b467a03d 100644 --- a/scm/driver/harness/repo.go +++ b/scm/driver/harness/repo.go @@ -75,6 +75,7 @@ func (s *repositoryService) CreateHook(ctx context.Context, repo string, input * in := new(hook) in.Enabled = true in.DisplayName = input.Name + in.UID = input.Name in.Secret = input.Secret in.Insecure = input.SkipVerify in.URL = input.Target @@ -134,6 +135,7 @@ type ( HasSecret bool `json:"has_secret"` Secret string `json:"secret"` ID int `json:"id"` + UID string `json:"uid"` Insecure bool `json:"insecure"` LatestExecutionResult string `json:"latest_execution_result"` ParentID int `json:"parent_id"` diff --git a/scm/driver/harness/testdata/webhooks/branch_create.json.golden b/scm/driver/harness/testdata/webhooks/branch_create.json.golden index 9bc611b3..a534de4c 100644 --- a/scm/driver/harness/testdata/webhooks/branch_create.json.golden +++ b/scm/driver/harness/testdata/webhooks/branch_create.json.golden @@ -1,5 +1,5 @@ { - "Ref": "aeafa0e2e4ec6909ad75cb8fad57c0b1eb5986e6", + "Ref": "refs/heads/new2", "Before": "0000000000000000000000000000000000000000", "After": "aeafa0e2e4ec6909ad75cb8fad57c0b1eb5986e6", "Repo": { diff --git a/scm/driver/harness/testdata/webhooks/branch_updated.json.golden b/scm/driver/harness/testdata/webhooks/branch_updated.json.golden index 1537f8d8..550cf3b1 100644 --- a/scm/driver/harness/testdata/webhooks/branch_updated.json.golden +++ b/scm/driver/harness/testdata/webhooks/branch_updated.json.golden @@ -1,5 +1,5 @@ { - "Ref": "92e21bfcddc1418079cddbb518ad6fd72917798a", + "Ref": "refs/heads/master", "Before": "a273c385628167932e10caaa58e12550c491f241", "After": "92e21bfcddc1418079cddbb518ad6fd72917798a", "Repo": { diff --git a/scm/driver/harness/webhook.go b/scm/driver/harness/webhook.go index 10f808e9..73a3d813 100644 --- a/scm/driver/harness/webhook.go +++ b/scm/driver/harness/webhook.go @@ -219,7 +219,7 @@ func convertPullRequestHook(src *pullRequestHook) *scm.PullRequestHook { func convertPushHook(src *pushHook) *scm.PushHook { return &scm.PushHook{ - Ref: src.Sha, + Ref: src.Ref.Name, Before: src.OldSha, After: src.Sha, Repo: convertRepo(src.Repo),