abd5580ea2d15a0ed29ebdde61305e078d93dc44

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

fix(webhook): we don't care about the default branch if it's missing

Diff

 1diff --git a/pkg/webhook/branch_tag.go b/pkg/webhook/branch_tag.go
 2index 5e545879ee71749b6bd48f20d6b37723b09de570..4062b0ef0dfe5450afa08b399010d78d910b275c 100644
 3--- a/pkg/webhook/branch_tag.go
 4+++ b/pkg/webhook/branch_tag.go
 5@@ -77,10 +77,7 @@ func NewBranchTagEvent(ctx context.Context, user proto.User, repo proto.Reposito
 6 
 7 	payload.Repository.Owner.ID = owner.ID
 8 	payload.Repository.Owner.Username = owner.Username
 9-	payload.Repository.DefaultBranch, err = getDefaultBranch(repo)
10-	if err != nil {
11-		return BranchTagEvent{}, err
12-	}
13+	payload.Repository.DefaultBranch, _ = getDefaultBranch(repo)
14 
15 	return payload, nil
16 }
17diff --git a/pkg/webhook/collaborator.go b/pkg/webhook/collaborator.go
18index 67a42aed9cd634877370a3d816aa964a0da395cb..c375aef9514072ed73ad60f6b057330176e789b3 100644
19--- a/pkg/webhook/collaborator.go
20+++ b/pkg/webhook/collaborator.go
21@@ -65,10 +65,7 @@ func NewCollaboratorEvent(ctx context.Context, user proto.User, repo proto.Repos
22 
23 	payload.Repository.Owner.ID = owner.ID
24 	payload.Repository.Owner.Username = owner.Username
25-	payload.Repository.DefaultBranch, err = getDefaultBranch(repo)
26-	if err != nil {
27-		return CollaboratorEvent{}, err
28-	}
29+	payload.Repository.DefaultBranch, _ = getDefaultBranch(repo)
30 
31 	collab, err := datastore.GetCollabByUsernameAndRepo(ctx, dbx, collabUsername, repo.Name())
32 	if err != nil {
33diff --git a/pkg/webhook/push.go b/pkg/webhook/push.go
34index a25d793797781e515bdf8cae883c86c81f9bce6c..985c75c3cac0ab93ebb5fdd90c2c1e43cbb33362 100644
35--- a/pkg/webhook/push.go
36+++ b/pkg/webhook/push.go
37@@ -74,10 +74,7 @@ func NewPushEvent(ctx context.Context, user proto.User, repo proto.Repository, r
38 		return PushEvent{}, err
39 	}
40 
41-	payload.Repository.DefaultBranch, err = getDefaultBranch(repo)
42-	if err != nil {
43-		return PushEvent{}, err
44-	}
45+	payload.Repository.DefaultBranch, _ = getDefaultBranch(repo)
46 
47 	rev := after
48 	if !git.IsZeroHash(before) {
49diff --git a/pkg/webhook/repository.go b/pkg/webhook/repository.go
50index 99fad6eec333ca883e459a56e3faccefe9260e92..30d1033a16b0df4a3386fdc4e9a1dd4db0f59167 100644
51--- a/pkg/webhook/repository.go
52+++ b/pkg/webhook/repository.go
53@@ -76,10 +76,7 @@ func NewRepositoryEvent(ctx context.Context, user proto.User, repo proto.Reposit
54 
55 	payload.Repository.Owner.ID = owner.ID
56 	payload.Repository.Owner.Username = owner.Username
57-	payload.Repository.DefaultBranch, err = getDefaultBranch(repo)
58-	if err != nil {
59-		return RepositoryEvent{}, err
60-	}
61+	payload.Repository.DefaultBranch, _ = getDefaultBranch(repo)
62 
63 	return payload, nil
64 }