chelouche9 commited on
Commit
d60f11c
Β·
1 Parent(s): c14cd7f

feat: support branches

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -63,9 +63,9 @@ def authenticate(password):
63
  def analyze_repos(repo_urls, role, seniority, assignment_details, focus_areas, password):
64
  auth_error, auth_success = authenticate(password)
65
  if auth_error:
66
- return auth_error, gr.update(visible=False) # If incorrect password, return error
67
-
68
- """Clone and analyze multiple GitHub repositories."""
69
  repo_urls = [url.strip() for url in repo_urls.split(",") if url.strip()]
70
 
71
  if not all(url.startswith("https://github.com/") for url in repo_urls):
@@ -79,16 +79,24 @@ def analyze_repos(repo_urls, role, seniority, assignment_details, focus_areas, p
79
  progress = gr.update(value="πŸ”„ Cloning repositories...", visible=True)
80
 
81
  for repo_url in repo_urls:
 
 
 
 
 
 
82
  repo_name = repo_url.split("/")[-1]
83
  repo_path = os.path.join(temp_dir, repo_name)
84
-
85
  try:
86
- git.Repo.clone_from(repo_url, repo_path)
 
 
87
  except Exception as e:
88
- repos_data += f"\n❌ Failed to clone `{repo_name}`: {str(e)}\n"
89
  continue
90
 
91
- repo_data = f"\nπŸ“‚ **Repository: {repo_name}**\n"
92
  file_count = 0
93
 
94
  for root, _, filenames in os.walk(repo_path):
@@ -134,7 +142,7 @@ def analyze_repos(repo_urls, role, seniority, assignment_details, focus_areas, p
134
 
135
  finally:
136
  shutil.rmtree(temp_dir) # Cleanup
137
-
138
  # Gradio UI
139
  with gr.Blocks() as app:
140
  gr.Markdown("# πŸ› οΈ AI-Powered Candidate Evaluation System")
 
63
  def analyze_repos(repo_urls, role, seniority, assignment_details, focus_areas, password):
64
  auth_error, auth_success = authenticate(password)
65
  if auth_error:
66
+ return auth_error, gr.update(visible=False)
67
+
68
+ """Clone and analyze multiple GitHub repositories, supporting specific branches."""
69
  repo_urls = [url.strip() for url in repo_urls.split(",") if url.strip()]
70
 
71
  if not all(url.startswith("https://github.com/") for url in repo_urls):
 
79
  progress = gr.update(value="πŸ”„ Cloning repositories...", visible=True)
80
 
81
  for repo_url in repo_urls:
82
+ # Extract branch if provided (URLs with "/tree/")
83
+ branch = None
84
+ if "/tree/" in repo_url:
85
+ repo_url, branch = repo_url.split("/tree/")[:2]
86
+ repo_url = repo_url.rstrip("/") # Clean base repo URL
87
+
88
  repo_name = repo_url.split("/")[-1]
89
  repo_path = os.path.join(temp_dir, repo_name)
90
+
91
  try:
92
+ repo = git.Repo.clone_from(repo_url + ".git", repo_path)
93
+ if branch:
94
+ repo.git.checkout(branch)
95
  except Exception as e:
96
+ repos_data += f"\n❌ Failed to clone `{repo_name}` (Branch: `{branch or 'default'}`): {str(e)}\n"
97
  continue
98
 
99
+ repo_data = f"\nπŸ“‚ **Repository: {repo_name}** (Branch: `{branch or 'default'}`)\n"
100
  file_count = 0
101
 
102
  for root, _, filenames in os.walk(repo_path):
 
142
 
143
  finally:
144
  shutil.rmtree(temp_dir) # Cleanup
145
+
146
  # Gradio UI
147
  with gr.Blocks() as app:
148
  gr.Markdown("# πŸ› οΈ AI-Powered Candidate Evaluation System")