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
Getting repos by name #61
Labels
enhancement
New feature or request
Comments
def get_repo_urls(self, repo_names: Iterable[str]) -> List[str]:
"""Get repo urls for all specified repo names in the current organization.
Assumes that the repos exist, there is no guarantee that they actually do
as checking this with the REST API takes too much time.
Args:
repo_names: A list of repository names.
Returns:
a list of urls corresponding to the repo names.
"""
org_url = self._api._org.html_url
return [
"{}/{}".format(org_url, repo_name) for repo_name in list(repo_names)
] |
def _repo_names_to_urls(repo_names: Iterable[str],
api: github_api.GitHubAPI) -> List[str]:
"""Use the repo_names to extract urls to the repos. Look for git repos
with the correct names in the local directory and create local uris for them.
For the rest, create urls to the repos assuming they are in the target
organization. Do note that theere is _not_ guarantee that the remote repos
exist as checking this takes too much time with the REST API.
A possible improvement would be to use the GraphQL API for this function.
Args:
repo_names: names of repositories.
api: A GitHubAPI instance.
Returns:
a list of urls corresponding to the repo_names.
"""
local = [
name for name in repo_names if util.is_git_repo(os.path.abspath(name))
]
non_local = [name for name in repo_names if name not in local]
non_local_urls = api.get_repo_urls(repo_names)
local_uris = [
pathlib.Path(os.path.abspath(repo_name)).as_uri()
for repo_name in local
]
return non_local_urls + local_uris |
This is miles faster (as no HTTP calls are made). It makes the tool so much more snappy. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Really doesn't work well for organizations with thousands of repos, it's just too slow.
The text was updated successfully, but these errors were encountered: