@@ -94,28 +94,33 @@ def get_contributors_to_file(self, path: str) -> List[dict]:
94
94
return []
95
95
96
96
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 []
119
124
120
125
def list_contributors (self , path : str ) -> List [dict ]:
121
126
path = path .replace ("\\ " , "/" )
0 commit comments