-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclone.py
More file actions
28 lines (22 loc) · 886 Bytes
/
clone.py
File metadata and controls
28 lines (22 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import requests
import os
def clone_github_org_repos():
# Prompt the user for the GitHub organization name
org_name = input("Enter the GitHub organization name: ")
# Make the URL to the input GitHub organization's repository page
org_url = f"https://api.github.com/orgs/{org_name}/repos?per_page=200"
# Send a GET request to the GitHub API
response = requests.get(org_url)
# Check if the request was successful
if response.status_code == 200:
# Parse the JSON response
repos = response.json()
# Clone all the repositories
for repo in repos:
repo_url = repo['html_url'] + '.git'
os.system(f"git clone {repo_url}")
print("Cloning completed.")
else:
print(f"Failed to fetch repositories for organization '{org_name}'")
if __name__ == "__main__":
clone_github_org_repos()