Skip to content

Commit

Permalink
🐛 Fix Branch-Protection scoring (ossf#3251)
Browse files Browse the repository at this point in the history
* fix: Verify if branch is required to be up to date before merge

Signed-off-by: Gabriela Gutierrez <gabigutierrez@google.com>

* docs: Comment tracking GraphQL bug

Signed-off-by: Gabriela Gutierrez <gabigutierrez@google.com>

* fix: Add validation if pointers are not null before accessing the values

Signed-off-by: Gabriela Gutierrez <gabigutierrez@google.com>

* fix: Delete debug log file

Signed-off-by: Gabriela Gutierrez <gabigutierrez@google.com>

---------

Signed-off-by: Gabriela Gutierrez <gabigutierrez@google.com>
Signed-off-by: André Backman <andre.backman@nokia.com>
  • Loading branch information
gabibguti authored and André Backman committed Jul 26, 2023
1 parent 4f2eaea commit 9740339
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion clients/githubrepo/branches.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,16 @@ func copyAdminSettings(src *branchProtectionRule, dst *clients.BranchProtectionR
copyBoolPtr(src.DismissesStaleReviews, &dst.RequiredPullRequestReviews.DismissStaleReviews)
if src.RequiresStatusChecks != nil {
copyBoolPtr(src.RequiresStatusChecks, &dst.CheckRules.RequiresStatusChecks)
copyBoolPtr(src.RequiresStrictStatusChecks, &dst.CheckRules.UpToDateBeforeMerge)
// TODO(#3255): Update when GitHub GraphQL bug is fixed
// Workaround for GitHub GraphQL bug https://github.com/orgs/community/discussions/59471
// The setting RequiresStrictStatusChecks should tell if the branch is required
// to be up to date before merge, but it only returns the correct value if
// RequiresStatusChecks is true. If RequiresStatusChecks is false, RequiresStrictStatusChecks
// is wrongly retrieved as true.
if src.RequiresStrictStatusChecks != nil {
upToDateBeforeMerge := *src.RequiresStatusChecks && *src.RequiresStrictStatusChecks
copyBoolPtr(&upToDateBeforeMerge, &dst.CheckRules.UpToDateBeforeMerge)
}
}
}

Expand Down

0 comments on commit 9740339

Please sign in to comment.