MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / fetch_all_branches

Function fetch_all_branches

diffusers/utils/fetch_latest_release_branch.py:25–46  ·  view source on GitHub ↗
(user, repo)

Source from the content-addressed store, hash-verified

23
24
25def fetch_all_branches(user, repo):
26 branches = [] # List to store all branches
27 page = 1 # Start from first page
28 while True:
29 # Make a request to the GitHub API for the branches
30 response = requests.get(f"https://api.github.com/repos/{user}/{repo}/branches", params={"page": page})
31
32 # Check if the request was successful
33 if response.status_code == 200:
34 # Add the branches from the current page to the list
35 branches.extend([branch["name"] for branch in response.json()])
36
37 # Check if there is a 'next' link for pagination
38 if "next" in response.links:
39 page += 1 # Move to the next page
40 else:
41 break # Exit loop if there is no next page
42 else:
43 print("Failed to retrieve branches:", response.status_code)
44 break
45
46 return branches
47
48
49def main():

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected