Skip to content

Commit 35488eb

Browse files
committed
chore: update committer plugin
1 parent fccd8c2 commit 35488eb

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

hooks/committer.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -94,28 +94,33 @@ def get_contributors_to_file(self, path: str) -> List[dict]:
9494
return []
9595

9696
authors = []
97-
r = requests.get(url=path, headers=get_header())
98-
self.last_request_return_code = r.status_code
99-
if r.status_code == 200:
100-
# Get login, url and avatar for each author. Ensure no duplicates.
101-
res = r.json()
102-
for commit in res:
103-
if (
104-
commit["author"]
105-
and commit["author"]["login"]
106-
and commit["author"]["login"]
107-
not in [author["login"] for author in authors]
108-
):
109-
authors.append(
110-
{
111-
"login": commit["author"]["login"],
112-
"name": commit["author"]["login"],
113-
"url": commit["author"]["html_url"],
114-
"avatar": commit["author"]["avatar_url"],
115-
}
116-
)
117-
return authors
118-
return []
97+
print(f"Getting contributors to {path}")
98+
for _ in range(5):
99+
r = requests.get(url=path, headers=get_header())
100+
self.last_request_return_code = r.status_code
101+
if r.status_code == 200:
102+
# Get login, url and avatar for each author. Ensure no duplicates.
103+
res = r.json()
104+
for commit in res:
105+
if (
106+
commit["author"]
107+
and commit["author"]["login"]
108+
and commit["author"]["login"]
109+
not in [author["login"] for author in authors]
110+
):
111+
authors.append(
112+
{
113+
"login": commit["author"]["login"],
114+
"name": commit["author"]["login"],
115+
"url": commit["author"]["html_url"],
116+
"avatar": commit["author"]["avatar_url"],
117+
}
118+
)
119+
return authors
120+
elif r.status_code in [401, 403]:
121+
print("Got a 401 or 403 error, not trying again")
122+
return []
123+
return []
119124

120125
def list_contributors(self, path: str) -> List[dict]:
121126
path = path.replace("\\", "/")

0 commit comments

Comments
 (0)