Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to create repo groupgs from GH orgs on the CLI #923

Merged
merged 3 commits into from
Sep 28, 2020

Conversation

ccarterlandis
Copy link
Contributor

Like the title says. Takes a GitHub org name, and (blindly, without dupe checking) creates a repo group with the same name. It then inserts all the repos from GitHub into that repo group.

@ccarterlandis ccarterlandis self-assigned this Sep 21, 2020
@ccarterlandis ccarterlandis added CLI Related to Augur's CLI feature-request Request for a new feature in Augur labels Sep 21, 2020
augur/cli/db.py Outdated Show resolved Hide resolved
@ccarterlandis ccarterlandis force-pushed the add-github-org-cli branch 2 times, most recently from b83db69 to 4209436 Compare September 21, 2020 19:28
Signed-off-by: Carter Landis <c@carterlandis.com>
Copy link
Contributor

@gabe-heim gabe-heim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment

augur/cli/db.py Outdated
all_repos.append(repo)

page+=1
repo_query_response = requests.get(org_query_response['repos_url'] + f"?per_page=100&page={page}", headers=headers).json()
Copy link
Contributor

@gabe-heim gabe-heim Sep 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

page incrementing should be after you hit the endpoint

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It increments it after because it hits it once first and then needs to get the second request inside the loop, but looking back at it now that was a really wacky way to implement the loop and I'm gonna refactor it.


for repo in all_repos:
logger.info(f"Adding {organization_name}/{repo['name']} ({repo['clone_url']})")
result = augur_app.database.execute(insert_repo_sql, repo_group_id=new_repo_group_id, repo_git=repo['clone_url'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a way to bulk insert which is faster, but if performance is not an issue (which I don't imagine it would be because I wouldn't think there would be an insane amount of repos in any org) then this implementation is just fine. So lmk if you want me to point you to some resources

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered a bulk insert but since there won't be too many repos for the vast majority of cases I went with this

Signed-off-by: Carter Landis <c@carterlandis.com>
@ccarterlandis
Copy link
Contributor Author

@gabe-heim made changes to that request loop so it makes more sense, thoughts?

@ccarterlandis
Copy link
Contributor Author

@gabe-heim pinging 🛠️

@gabe-heim gabe-heim merged commit 7f428a6 into dev Sep 28, 2020
@ccarterlandis ccarterlandis deleted the add-github-org-cli branch November 2, 2020 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI Related to Augur's CLI feature-request Request for a new feature in Augur
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants