Spaces:
Sleeping
Sleeping
fix: defined clean fn
Browse files
app.py
CHANGED
|
@@ -235,6 +235,22 @@ def read_file_safely(file_path):
|
|
| 235 |
return False, error_msg
|
| 236 |
return False, "Tidak dapat membaca file dengan encoding yang didukung"
|
| 237 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
def create_ui():
|
| 239 |
with gr.Blocks(title="Analisis Repository dengan Ollama", css=CUSTOM_CSS) as app:
|
| 240 |
gr.Markdown(f"""
|
|
|
|
| 235 |
return False, error_msg
|
| 236 |
return False, "Tidak dapat membaca file dengan encoding yang didukung"
|
| 237 |
|
| 238 |
+
def handle_clone(url, token, branch_name):
|
| 239 |
+
"""Handle repository cloning and file listing"""
|
| 240 |
+
print(f"\nMengkloning repository: {url}")
|
| 241 |
+
success, result = clone_repository(url, token, branch_name if branch_name else None)
|
| 242 |
+
if success:
|
| 243 |
+
try:
|
| 244 |
+
files = [str(p) for p in Path(result).rglob('*')
|
| 245 |
+
if p.is_file() and '.git' not in str(p)]
|
| 246 |
+
print(f"Menemukan {len(files)} file dalam repository")
|
| 247 |
+
return f"Berhasil mengkloning repository ke: {result}", gr.Dropdown(choices=files)
|
| 248 |
+
except Exception as e:
|
| 249 |
+
error_msg = f"Error saat mencari file: {str(e)}"
|
| 250 |
+
print(error_msg)
|
| 251 |
+
return error_msg, None
|
| 252 |
+
return f"Gagal mengkloning: {result}", None
|
| 253 |
+
|
| 254 |
def create_ui():
|
| 255 |
with gr.Blocks(title="Analisis Repository dengan Ollama", css=CUSTOM_CSS) as app:
|
| 256 |
gr.Markdown(f"""
|