Skip to content

Commit e143a0f

Browse files
fix: add bypass_actors to default branch rules
1 parent abca58c commit e143a0f

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

afterpython/tools/_git.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,32 @@ def get_github_username() -> str | None:
106106
return result.stdout.strip()
107107

108108

109+
def get_current_user_id() -> int | None:
110+
"""
111+
Get the GitHub user ID of the currently authenticated user.
112+
113+
Returns:
114+
User ID or None if error
115+
"""
116+
if not is_gh_authenticated():
117+
return None
118+
119+
result = subprocess.run(
120+
["gh", "api", "user", "--jq", ".id"],
121+
capture_output=True,
122+
text=True,
123+
)
124+
125+
if result.returncode != 0:
126+
print(f"Error fetching user ID: {result.stderr}")
127+
return None
128+
129+
try:
130+
return int(result.stdout.strip())
131+
except ValueError:
132+
print("Error: Failed to parse user ID")
133+
return None
134+
135+
109136
# TODO: use gh's token for pygithub to get repo issues
110137
# def get_repo_issues(owner: str, repo: str) -> list[dict]:

afterpython/tools/branch_rules.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
"exclude": [], # No exclusions
2121
}
2222
},
23+
"bypass_actors": [
24+
{
25+
"actor_id": 5, # Repository admin role
26+
"actor_type": "RepositoryRole",
27+
"bypass_mode": "pull_request",
28+
}
29+
],
2330
"rules": [ # Array of protection rules
2431
# Rule 1: No Force Pushes
2532
{"type": "non_fast_forward"}, # Prevents git push --force

0 commit comments

Comments
 (0)