Skip to content

Commit f37cbf9

Browse files
authored
Merge pull request #61 from datalad/gh-60
GIN family: Exclude private repos
2 parents cca1138 + 0151e23 commit f37cbf9

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/find_datalad_repos/gin.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,22 @@ def search_repositories(self) -> Iterator[dict[str, Any]]:
7676
# custom RetryConfig above) once
7777
# <https://github.com/G-Node/gogs/issues/148> is resolved:
7878
###
79-
# for datum in self.paginate("/repos/search"):
79+
# for datum in self.paginate(
80+
# "/repos/search", params={"private": "false", "is_private": "false"}
81+
# ):
8082
# yield GINRepo.from_data(datum)
8183
###
8284
page = 1
8385
while True:
8486
try:
85-
r = self.get("/repos/search", params={"page": page}, raw=True)
87+
r = self.get(
88+
"/repos/search",
89+
# `private` and `is_private` are supported by the forgejo
90+
# family (e.g., hub.datalad.org) but not GIN itself; for
91+
# that, we filter on the "private" field below.
92+
params={"page": page, "private": "false", "is_private": "false"},
93+
raw=True,
94+
)
8695
except PrettyHTTPError as e:
8796
if e.response.status_code == 500:
8897
log.warning(
@@ -102,6 +111,8 @@ def search_repositories(self) -> Iterator[dict[str, Any]]:
102111

103112
def get_datalad_repos(self) -> Iterator[GINRepo]:
104113
for datum in self.search_repositories():
114+
if datum.get("private", False):
115+
continue
105116
repo = GINRepo.from_data(datum)
106117
if self.has_datalad_config(repo.name, datum["default_branch"]):
107118
log.info("Found DataLad repo on GIN: %r (ID: %d)", repo.name, repo.id)

0 commit comments

Comments
 (0)