github-org-manager 0.4.0__tar.gz → 0.4.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: github-org-manager
3
- Version: 0.4.0
3
+ Version: 0.4.1
4
4
  Summary: Manage a GitHub Organization, its teams, repository permissions, and more
5
5
  Home-page: https://github.com/OpenRailAssociation/github-org-manager
6
6
  License: Apache-2.0
@@ -182,16 +182,16 @@ class GHorg: # pylint: disable=too-many-instance-attributes
182
182
  self._get_org_members()
183
183
 
184
184
  # Get open invitations
185
- open_invitations = [user.login for user in self.org.invitations()]
185
+ open_invitations = [user.login.lower() for user in self.org.invitations()]
186
186
 
187
187
  for team, team_attrs in self.current_teams.items():
188
188
  # Update current team members with dict[NamedUser, str (role)]
189
189
  team_attrs["members"] = self._get_current_team_members(team)
190
190
 
191
191
  # For the rest of the function however, we use just the login name
192
- # for each current user
192
+ # for each current user. All lower-case
193
193
  current_team_members = {
194
- user.login: role for user, role in team_attrs["members"].items()
194
+ user.login.lower(): role for user, role in team_attrs["members"].items()
195
195
  }
196
196
 
197
197
  # Handle the team not being configured locally
@@ -209,16 +209,17 @@ class GHorg: # pylint: disable=too-many-instance-attributes
209
209
  else:
210
210
  team_configuration = {}
211
211
 
212
- # Analog to team_attrs["members"], add members and maintainers to shared
213
- # dict with respective role, while maintainer role dominates
212
+ # Analog to team_attrs["members"], add members and maintainers to
213
+ # shared dict with respective role, while maintainer role dominates.
214
+ # All user names shall be lower-case to ease comparison
214
215
  configured_users: dict[str, str] = {}
215
216
  for config_role in ("member", "maintainer"):
216
217
  team_members = self._get_configured_team_members(
217
218
  team_configuration, team.name, config_role
218
219
  )
219
220
  for team_member in team_members:
220
- # Add user with role to dict
221
- configured_users.update({team_member: config_role})
221
+ # Add user with role to dict, in lower-case
222
+ configured_users.update({team_member.lower(): config_role})
222
223
 
223
224
  # Consider all GitHub organisation team maintainers if they are member of the team
224
225
  # This is because GitHub API returns them as maintainers even if they are just members
@@ -227,7 +228,7 @@ class GHorg: # pylint: disable=too-many-instance-attributes
227
228
  logging.debug(
228
229
  "Overriding role of organisation owner '%s' to maintainer", user.login
229
230
  )
230
- configured_users[user.login] = "maintainer"
231
+ configured_users[user.login.lower()] = "maintainer"
231
232
 
232
233
  # Only make edits to the team membership if the current state differs from config
233
234
  if configured_users == current_team_members:
@@ -278,8 +279,11 @@ class GHorg: # pylint: disable=too-many-instance-attributes
278
279
  # Loop through all current members. Remove them if they are not configured
279
280
  for current_user in current_team_members:
280
281
  if current_user not in configured_users:
282
+ logging.debug("User '%s' not found within configured users", current_user)
281
283
  # Turn user to GitHub object, trying to find them
282
284
  if not (gh_user := self._resolve_gh_username(current_user, team.name)):
285
+ # If the user cannot be found for some reason, log an
286
+ # error and skip this loop
283
287
  continue
284
288
  if team.has_in_members(gh_user):
285
289
  logging.info(
@@ -471,7 +475,13 @@ class GHorg: # pylint: disable=too-many-instance-attributes
471
475
  """Combine multiple lists into one while removing duplicates"""
472
476
  complete = []
473
477
  for single_list in lists:
474
- complete.extend(single_list)
478
+ if single_list is not None:
479
+ complete.extend(single_list)
480
+ else:
481
+ logging.debug(
482
+ "A list that we attempted to extend to another was None. "
483
+ "This probably happened because a 'member:' or 'maintainer:' key was left empty"
484
+ )
475
485
 
476
486
  return list(set(complete))
477
487
 
@@ -561,7 +571,7 @@ class GHorg: # pylint: disable=too-many-instance-attributes
561
571
  )
562
572
  )
563
573
  else:
564
- self.configured_repos_collaborators[repo][team_member] = perm
574
+ self.configured_repos_collaborators[repo][team_member.lower()] = perm
565
575
 
566
576
  def _convert_graphql_perm_to_rest(self, permission: str) -> str:
567
577
  """Convert a repo permission coming from the GraphQL API to the ones
@@ -627,12 +637,12 @@ class GHorg: # pylint: disable=too-many-instance-attributes
627
637
 
628
638
  # Extract relevant data
629
639
  for collaborator in collaborators:
630
- login = collaborator["node"]["login"]
640
+ login: str = collaborator["node"]["login"]
631
641
  # Skip entry if collaborator is org owner, which is "admin" anyway
632
- if login in [user.login for user in self.org_owners]:
642
+ if login.lower() in [user.login.lower() for user in self.org_owners]:
633
643
  continue
634
644
  permission = self._convert_graphql_perm_to_rest(collaborator["permission"])
635
- self.current_repos_collaborators[repo][login] = permission
645
+ self.current_repos_collaborators[repo][login.lower()] = permission
636
646
 
637
647
  def _get_current_repos_and_user_perms(self):
638
648
  """Get all repos, their current collaborators and their permissions"""
@@ -4,7 +4,7 @@
4
4
 
5
5
  [tool.poetry]
6
6
  name = "github-org-manager"
7
- version = "0.4.0"
7
+ version = "0.4.1"
8
8
  description = "Manage a GitHub Organization, its teams, repository permissions, and more"
9
9
  authors = ["Max Mehl <max.mehl@deutschebahn.com>"]
10
10
  readme = "README.md"
@@ -39,7 +39,7 @@ mypy = "^1.9.0"
39
39
  pylint = "^3.1.0"
40
40
  types-pyyaml = "^6.0.12.20240311"
41
41
  types-requests = "^2.32.0.20240712"
42
- bump2version = "^1.0.1"
42
+ bump-my-version = "^0.26.0"
43
43
 
44
44
  [build-system]
45
45
  requires = ["poetry-core"]
@@ -60,3 +60,16 @@ files = ["gh_org_mgr/*.py"]
60
60
  # Pylint
61
61
  [tool.pylint.'MESSAGES CONTROL']
62
62
  disable = "fixme"
63
+
64
+ # Bump-My-Version
65
+ [tool.bumpversion]
66
+ commit = true
67
+ tag = true
68
+ allow_dirty = false
69
+ tag_name = "v{new_version}"
70
+
71
+ [[tool.bumpversion.files]]
72
+ filename = "pyproject.toml"
73
+ regex = true
74
+ search = "^version = \"{current_version}\""
75
+ replace = "version = \"{new_version}\""