Skip to content

Commit 93bdfa1

Browse files
committed
Add patch to prevent commit signoff is enforced error
1 parent 01640ed commit 93bdfa1

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Prevent 422 Commit signoff is enforced by the organization and cannot be disabled.
2+
3+
This patch fixes a bug in the GitHub API 2022-11-28 version where updating a repository
4+
with web_commit_signoff_required=true throws a 422 error when the field is already true.
5+
6+
It checks if the web_commit_signoff_required field has actually changed during a
7+
repository update. If the field hasn't changed and is already true, it's removed from
8+
the update request to avoid the API error.
9+
10+
For more information: https://github.com/integrations/terraform-provider-github/issues/2077
11+
12+
diff --git a/github/resource_github_repository.go b/github/resource_github_repository.go
13+
index f28cc4c6..aa6184c0 100644
14+
--- a/github/resource_github_repository.go
15+
+++ b/github/resource_github_repository.go
16+
@@ -765,6 +765,14 @@ func resourceGithubRepositoryUpdate(d *schema.ResourceData, meta interface{}) er
17+
repoReq.DefaultBranch = github.String(d.Get("default_branch").(string))
18+
}
19+
20+
+ // There's a bug in the GitHub 2022-11-28 version, that throws a 422 error
21+
+ // whenever the `web_commit_signoff_required` is set to true, even when it
22+
+ // is already true.
23+
+ if !d.HasChange("web_commit_signoff_required") && d.Get("web_commit_signoff_required").(bool) {
24+
+ // remove the field from the request
25+
+ repoReq.WebCommitSignoffRequired = nil
26+
+ }
27+
+
28+
repoName := d.Id()
29+
owner := meta.(*Owner).name
30+
ctx := context.WithValue(context.Background(), ctxId, d.Id())

0 commit comments

Comments
 (0)