Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
chdsbd committed Jun 20, 2024
1 parent 3877a8a commit 2a64792
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 78 deletions.
84 changes: 39 additions & 45 deletions bot/kodiak/queries/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,54 +52,50 @@ class GraphQLResponse(TypedDict, total=False):
query (
$owner: String!,
$repo: String!,
$baseRef: String!,
$qualifiedBaseRef: String!,
$rootConfigFileExpression: String!,
$githubConfigFileExpression: String!,
$orgRootConfigFileExpression: String,
$orgGithubConfigFileExpression: String
) {
repository(owner: $owner, name: $repo) {
refs(refPrefix: "refs/heads/", query: $baseRef, first: 1) {
edges {
node {
name
branchProtectionRule {
requiresStatusChecks
requiredStatusCheckContexts
requiresCodeOwnerReviews
requiresStrictStatusChecks
requiresLinearHistory
requiresConversationResolution
requiresCommitSignatures
restrictsPushes
requiredApprovingReviewCount
requireLastPushApproval
requiredStatusChecks {
app {
slug
}
context
}
ref(qualifiedName: $qualifiedBaseRef) {
name
branchProtectionRule {
requiresStatusChecks
requiredStatusCheckContexts
requiresCodeOwnerReviews
requiresStrictStatusChecks
requiresLinearHistory
requiresConversationResolution
requiresCommitSignatures
restrictsPushes
requiredApprovingReviewCount
requireLastPushApproval
requiredStatusChecks {
app {
slug
}
context
}
pushAllowances(first: 100) {
nodes {
actor {
... on Team {
name
}
... on Actor {
login
}
... on User {
login
}
... on App {
databaseId
}
}
pushAllowances(first: 100) {
nodes {
actor {
... on Team {
name
}
... on Actor {
login
}
... on User {
login
}
... on App {
databaseId
}
}
}
Expand Down Expand Up @@ -634,9 +630,7 @@ def get_branch_protection(
*, config_response: Dict[str, Any], ref_name: str
) -> Optional[BranchProtectionRule]:
try:
branchProtectionRule = config_response["repository"]["refs"]["edges"][0][
"node"
]["branchProtectionRule"]
branchProtectionRule = config_response["repository"]["ref"]["branchProtectionRule"]
try:
return BranchProtectionRule.parse_obj(branchProtectionRule)
except ValueError:
Expand Down Expand Up @@ -993,7 +987,7 @@ async def get_config_for_ref(
variables=dict(
owner=self.owner,
repo=self.repo,
baseRef=ref,
qualifiedBaseRef=f"refs/heads/{ref}",
rootConfigFileExpression=repo_root_config_expression,
githubConfigFileExpression=repo_github_config_expression,
orgRootConfigFileExpression=org_root_config_expression,
Expand Down
58 changes: 25 additions & 33 deletions bot/kodiak/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,39 +95,31 @@ async def test_get_config_for_ref_dot_github(
"githubConfigFile": {
"text": "# .github/.kodiak.toml\nversion = 1\nmerge.method = 'rebase'"
},
"refs": {
"edges": [
{
"node": {
"branchProtectionRule": {
"matchingRefs": {
"nodes": [{"name": "master"}]
},
"requiresApprovingReviews": True,
"requiredApprovingReviewCount": 2,
"requiresStatusChecks": True,
"requiredStatusCheckContexts": [
"ci/circleci: backend_lint",
"ci/circleci: backend_test",
"ci/circleci: frontend_lint",
"ci/circleci: frontend_test",
"WIP (beta)",
],
"requiresStrictStatusChecks": True,
"requiresCodeOwnerReviews": False,
"requiresCommitSignatures": False,
"requiresConversationResolution": False,
"restrictsPushes": True,
"pushAllowances": {
"nodes": [
{"actor": {}},
{"actor": {"databaseId": 53453}},
]
},
}
}
}
]
"ref": {
"branchProtectionRule": {
"matchingRefs": {"nodes": [{"name": "master"}]},
"requiresApprovingReviews": True,
"requiredApprovingReviewCount": 2,
"requiresStatusChecks": True,
"requiredStatusCheckContexts": [
"ci/circleci: backend_lint",
"ci/circleci: backend_test",
"ci/circleci: frontend_lint",
"ci/circleci: frontend_test",
"WIP (beta)",
],
"requiresStrictStatusChecks": True,
"requiresCodeOwnerReviews": False,
"requiresCommitSignatures": False,
"requiresConversationResolution": False,
"restrictsPushes": True,
"pushAllowances": {
"nodes": [
{"actor": {}},
{"actor": {"databaseId": 53453}},
]
},
}
},
}
}
Expand Down

0 comments on commit 2a64792

Please sign in to comment.