Skip to content

Commit

Permalink
Explictly exclude archived repos for clarity
Browse files Browse the repository at this point in the history
Previously an unpredictable subset of archived repos were excluded based
on team ownership records (see previous commit for details). For clarity
and consistently we are now excluding them all explicitly.
  • Loading branch information
benbc committed Mar 13, 2024
1 parent 813ca2d commit 686a7d1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
12 changes: 6 additions & 6 deletions metrics/github/repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def tech_repos(client, org):
for team in _TECH_TEAMS:
repo_names.extend(query.team_repos(client, org, team))

return [r for r in query.repos(client, org) if r.name in repo_names]
return [r for r in _active_repos(client, org) if r.name in repo_names]


def get_repo_ownership(client, orgs):
Expand All @@ -18,11 +18,7 @@ def get_repo_ownership(client, orgs):
for repo in query.team_repos(client, org, team):
ownership[repo] = team

active_repos = [
repo for repo in query.repos(client, org) if not repo.is_archived()
]

for repo in active_repos:
for repo in _active_repos(client, org):
if repo.name in ownership:
team = ownership[repo.name]
else:
Expand All @@ -32,5 +28,9 @@ def get_repo_ownership(client, orgs):
return repo_owners


def _active_repos(client, org):
return [repo for repo in query.repos(client, org) if not repo.is_archived()]


# GitHub slugs for the teams we're interested in
_TECH_TEAMS = ["team-rap", "team-rex", "tech-shared"]
20 changes: 20 additions & 0 deletions tests/metrics/github/test_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,26 @@ def test_excludes_non_tech_owned_repos(patch):
assert len(repos.tech_repos(None, "opensafely-core")) == 0


def test_excludes_archived_repos(patch):
patch(
"team_repos",
{
"opensafely-core": {
"team-rap": ["other-repo"],
"team-rex": [],
"tech-shared": [],
}
},
)
patch(
"repos",
[
repo("opensafely-core", "other-repo", archived_on=date.min),
],
)
assert len(repos.tech_repos(None, "opensafely-core")) == 0


def test_looks_up_ownership(patch):
patch(
"repos",
Expand Down

0 comments on commit 686a7d1

Please sign in to comment.