Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix Branch-Protection scoring #3251

Merged
merged 5 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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
gabibguti marked this conversation as resolved.
Show resolved Hide resolved
// 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)
}

Check warning on line 202 in clients/githubrepo/branches.go

View check run for this annotation

Codecov / codecov/patch

clients/githubrepo/branches.go#L193-L202

Added lines #L193 - L202 were not covered by tests
}
}

Expand Down
24 changes: 24 additions & 0 deletions gabi.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
2023/07/10 12:01:24 RequiresStatusChecks: false
gabibguti marked this conversation as resolved.
Show resolved Hide resolved
2023/07/10 12:01:24 RequiresStrictStatusChecks: true
2023/07/10 12:01:24 upToDateBeforeMerge: false
2023/07/10 12:01:25 maxReviewScore: 1
2023/07/10 12:01:25 maxAdminReviewScore: 2
2023/07/10 12:01:25 reviewScore: 1
2023/07/10 12:01:25 adminReviewScore: 1
2023/07/10 12:01:25 score: 5.000000
2023/07/10 12:01:59 RequiresStatusChecks: true
2023/07/10 12:01:59 RequiresStrictStatusChecks: false
2023/07/10 12:01:59 upToDateBeforeMerge: false
2023/07/10 12:01:59 maxReviewScore: 1
2023/07/10 12:01:59 maxAdminReviewScore: 2
2023/07/10 12:01:59 reviewScore: 1
2023/07/10 12:01:59 adminReviewScore: 1
2023/07/10 12:01:59 score: 5.000000
2023/07/10 12:02:19 RequiresStatusChecks: true
2023/07/10 12:02:19 RequiresStrictStatusChecks: true
2023/07/10 12:02:19 upToDateBeforeMerge: true
2023/07/10 12:02:19 maxReviewScore: 1
2023/07/10 12:02:19 maxAdminReviewScore: 2
2023/07/10 12:02:19 reviewScore: 1
2023/07/10 12:02:19 adminReviewScore: 2
2023/07/10 12:02:19 score: 6.000000
Loading