Skip to content

Commit

Permalink
🐛 Fix Branch-Protection scoring (#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>
  • Loading branch information
gabibguti authored Jul 18, 2023
1 parent ac6e027 commit b9ad5c4
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 b9ad5c4

Please sign in to comment.