Skip to content

Commit 3d38960

Browse files
committed
feat: GitHub bot exclusion.
1 parent 33bca53 commit 3d38960

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

fame/github_tracker.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ def __init__(self, message):
3030

3131

3232
class RepoTracker:
33+
KNOWN_BOTS = ['pyup-bot']
34+
3335
def configure(self, user, owner, repo,
3436
sourcerer_api_origin=None,
3537
sourcerer_api_secret=None,
@@ -214,6 +216,10 @@ def _update_latest_commits(self, repo, avatars):
214216
except:
215217
print('w Author, date, or avatar missing. Skipping %s' % sha)
216218

219+
if author in RepoTracker.KNOWN_BOTS:
220+
print('i Skipping bot commit %s by %s' % (sha, author))
221+
continue
222+
217223
commit = pb.Commit(sha=sha, timestamp=commit_date, username=author)
218224
commits.append(commit)
219225

@@ -239,10 +245,15 @@ def _update_top_contributors(self, repo, avatars):
239245
contributors = self._get_json(r)
240246

241247
for contrib in contributors[:20]:
248+
username = contrib['login']
249+
if username in RepoTracker.KNOWN_BOTS:
250+
print('i Skipping bot in top contributors: %s' % username)
251+
continue
252+
242253
committer = repo.top_contributors.add()
243-
committer.username = contrib['login']
254+
committer.username = username
244255
committer.num_commits = contrib['contributions']
245-
avatars[committer.username] = contrib['avatar_url']
256+
avatars[username] = contrib['avatar_url']
246257

247258
def _update_new_contributors(self, repo):
248259
repo.ClearField('new_contributors')

0 commit comments

Comments
 (0)