Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3802970
D2466.id6215.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D2466.id6215.diff
View Options
diff --git a/github/list-repositories.py b/github/list-repositories.py
--- a/github/list-repositories.py
+++ b/github/list-repositories.py
@@ -10,7 +10,7 @@
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-def query_api_repositories_for_names(github_account, page, repositories):
+def query_api_repositories(github_account, page, repositories):
url = f"https://api.github.com/orgs/{github_account}/repos?page={page}"
response = requests.get(url)
@@ -18,18 +18,27 @@
raise RuntimeError(
f"HTTP error {response.status_code}: {response.text}")
- new_repositories = [repo["name"] for repo in response.json()]
+ new_repositories = response.json()
if len(new_repositories) == 0:
# We've all of them.
return repositories
- return query_api_repositories_for_names(
+ return query_api_repositories(
github_account, page + 1, repositories + new_repositories)
-def get_all_repositories_names(github_account):
- return query_api_repositories_for_names(github_account, 1, [])
+def get_all_repositories(github_account):
+ return query_api_repositories(github_account, 1, [])
+
+
+def print_repository(repository_info, options):
+ line = repository_info["name"]
+
+ if options["with_branch"]:
+ line += f",{repository_info['default_branch']}"
+
+ print(line)
# -------------------------------------------------------------
@@ -37,14 +46,22 @@
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-def run(github_account):
- for repository in get_all_repositories_names(github_account):
- print(repository)
+def run(github_account, options):
+ for repository in get_all_repositories(github_account):
+ print_repository(repository, options)
if __name__ == "__main__":
+ options = {
+ "with_branch": False,
+ }
+
try:
- run(sys.argv[1])
+ for extra_arg in sys.argv[2:]:
+ if extra_arg == '-b':
+ options["with_branch"] = True
+
+ run(sys.argv[1], options)
except IndexError:
print("Usage:", sys.argv[0], "<GitHub org account>", file=sys.stderr)
sys.exit(2)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 30, 13:33 (18 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2272922
Default Alt Text
D2466.id6215.diff (2 KB)
Attached To
Mode
D2466: Allow to query branch for repository
Attached
Detach File
Event Timeline
Log In to Comment