Skip to content

Commit

Permalink
add very fast GitHub total star count
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Mar 29, 2019
1 parent 4ae908c commit d33948f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
14 changes: 9 additions & 5 deletions ListAllGithubRepos.py
Expand Up @@ -17,9 +17,12 @@ def main():
p = ArgumentParser(description='list all Github repos for a particular user')
p.add_argument('user', help='Github username')
p.add_argument('oauth', help='Oauth filename', nargs='?')

p.add_argument('-b', '--branch', help='branch to consider')
p.add_argument('-stars', help='only get star count', action='store_true')
p.add_argument('-v', '--verbose', action='store_true')
p = p.parse_args()
dat, ahead = gu.repo_prober(p.user, p.oauth)

dat, ahead = gu.repo_prober(p.user, p.oauth, p.branch, p.stars, p.verbose)

datnz = dat[~(dat == 0).all(axis=1)]
# %% Stars and Forks
Expand All @@ -30,9 +33,10 @@ def main():

print(datnz.sort_values(['stars', 'forks'], ascending=False))
# %% Forks ahead
print(f'\n{p.user} Forks that are ahead by N commits')
for a in ahead:
print(a)
if ahead:
print(f'\n{p.user} Forks that are ahead by N commits')
for a in ahead:
print(a)


if __name__ == '__main__':
Expand Down
10 changes: 9 additions & 1 deletion README.md
Expand Up @@ -20,6 +20,14 @@ is showing which forks of your repos have had changes "ahead of" your code.
This shows your code is being improved, even if the forked repo didn't make a pull request.
I don't know of any other easy way out there to find this.

Count how many total GitHub stars an account has:

```sh
python ListAllGithubRepos.py githubusername oauth.key -stars
```

That will take only a second or two even for large numbers of repos.

Also see Git [utilities](https://github.com/scivision/gitedu) for managing large (100+) numbers of users / teams, particularly for education and institutions.

## Install
Expand Down Expand Up @@ -71,7 +79,7 @@ For private repos, simply clone with SSH as usual
### Preview all changed Jekyll files

This is for a website made using
[Jekyll](https://www.scivision.co/create-jekyll-github-pages-website):
[Jekyll](https://www.scivision.dev/create-jekyll-github-pages-website):
```sh
ActOnChanged -j
```
Expand Down
8 changes: 4 additions & 4 deletions gitutils/github_repo_stats.py
Expand Up @@ -13,6 +13,7 @@


def repo_prober(user: str, oauth: Path = None, branch: str = None,
starsonly: bool = False,
verbose: bool = False) -> Tuple[pd.DataFrame, List[Tuple[str, int]]]:
"""
probe all GitHub repos for a user to see how much forks of each repo are ahead.
Expand Down Expand Up @@ -50,14 +51,13 @@ def repo_prober(user: str, oauth: Path = None, branch: str = None,
ahead: List[Tuple[str, int]] = []

for repo in repos:
ahead = fork_prober(repo, sess, ahead, branch)
if not starsonly:
ahead += fork_prober(repo, sess, ahead, branch, verbose)

dat.loc[repo.name, :] = (repo.forks_count, repo.stargazers_count)

check_api_limit(sess)

sleep(1.)

return dat, ahead


Expand Down Expand Up @@ -98,7 +98,7 @@ def fork_prober(repo, sess,

forks = repo.get_forks()
for fork in forks:
sleep(0.2) # don't hammer the API, avoiding 502 errors
sleep(0.1) # don't hammer the API, avoiding 502 errors

check_api_limit(sess)

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = gitutils
version = 1.2.2
version = 1.2.3
author = Michael Hirsch, Ph.D.
author_email = scivision@users.noreply.github.com
description = concurrent, pipelined, platform-agnostic Git utilities for managing a large number of Git repositories
Expand Down

0 comments on commit d33948f

Please sign in to comment.