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

Create pr_commit_counts.py #44

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Create pr_commit_counts.py #44

wants to merge 4 commits into from

Conversation

nnayar-r2c
Copy link
Contributor

New utility to allow customers to count total number of pull request events for all repos in a given GitHub org.

Copy link
Contributor

@armchairlinguist armchairlinguist left a comment

Choose a reason for hiding this comment

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

Approved with comments :)

else:
url = None
else:
raise Exception(f"GitHub API request failed with status code {response.status_code}")
Copy link
Contributor

Choose a reason for hiding this comment

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

This is more of a for-the-future comment - we might want to think about better ways to handle an error than aborting entirely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will look at in the future

utilities/pr_commit_counts/pr_commit_counts.py Outdated Show resolved Hide resolved
Comment on lines 35 to 36
# organization = input("Enter the organization name: ")
# github_token = input("Enter your GitHub access token: ")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# organization = input("Enter the organization name: ")
# github_token = input("Enter your GitHub access token: ")
organization = input("Enter the organization name: ")

The input option for the org name is fine, there's no security concern there. If you wanted to be fancy, you could allow an env var here too, and only request input if it's not set. It would probably look something like this:

organization = os.getenv("GITHUB_ORG")
if organization is None:
  organization = input("Enter the organization name: ")

If you have a better style idea no problem, the main thing is to handle the options gracefully :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

# organization = input("Enter the organization name: ")
# github_token = input("Enter your GitHub access token: ")

organization = "ORGANIZATION_NAME" # Replace with your organization name
Copy link
Contributor

Choose a reason for hiding this comment

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

If you make the change above, you can remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

utilities/pr_commit_counts/pr_commit_counts.py Outdated Show resolved Hide resolved
utilities/pr_commit_counts/pr_commit_counts.py Outdated Show resolved Hide resolved
utilities/pr_commit_counts/pr_commit_counts.py Outdated Show resolved Hide resolved
@@ -16,27 +17,28 @@ def get_paginated_results(url, headers):
raise Exception(f"GitHub API request failed with status code {response.status_code}")
return results

def get_repos(organization, headers):
def get_repos(BASE_URL, organization, headers):
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm this wasn't quite what I meant - it makes more sense to just define BASE_URL as a constant in the file as you did, and use it everywhere - you don't have to make it an argument that you pass in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants