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

Handle new team when making a dry-run #62

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Changes from all 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
20 changes: 19 additions & 1 deletion gh_org_mgr/_gh_org.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,25 @@ def _create_perms_changelist_for_teams(
continue

# Convert team name to Team object
team = self.org.get_team_by_slug(self._sluggify_teamname(team_name))
try:
team = self.org.get_team_by_slug(self._sluggify_teamname(team_name))
# Team not found, probably because a new team should be created, but it's a dry-run
except UnknownObjectException:
logging.debug(
"Team %s not found, probably because it should be created but it's a dry-run",
team_name,
)
# Initialise a new Team() object with the name, manually
team = Team(
requester=None, # type: ignore
headers={}, # No headers required
attributes={
"id": 0,
"name": team_name,
"slug": self._sluggify_teamname(team_name),
},
completed=True, # Mark as fully initialized
)

# Get configured repo permissions
for repo, perm in team_attrs.get("repos", {}).items():
Expand Down
Loading