Skip to content

Commit 59d34d9

Browse files
author
Douglas
committed
Added automatic repo name detection.
1 parent f6f8e14 commit 59d34d9

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

main.py

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,47 @@
55
import os
66
import sys
77
import inspect
8+
import subprocess
9+
10+
from torchgen.executorch.api.et_cpp import return_names
811

912
GITHUB_TOKEN = None
1013

1114
# Define the current version of the app
12-
APP_VERSION = "1.0.0a"
15+
APP_VERSION = "1.0.1a"
16+
17+
def get_repo_name():
18+
"""
19+
Dynamically retrieves the repository name from the Git remote URL.
20+
"""
21+
try:
22+
# Run 'git remote get-url origin' to get the remote URL
23+
remote_url = subprocess.check_output(
24+
["git", "remote", "get-url", "origin"], text=True
25+
).strip()
26+
27+
# Extract the repo name from the URL
28+
if remote_url.startswith("https://") or remote_url.startswith("http://"):
29+
repo_name = remote_url.split("/")[-2] + "/" + remote_url.split("/")[-1].replace(".git", "")
30+
elif remote_url.startswith("git@"):
31+
repo_name = remote_url.split(":")[-1].replace(".git", "")
32+
else:
33+
repo_name = None
34+
if repo_name is not None:
35+
print(f"Detected repository: {repo_name}")
36+
else:
37+
print(f"Could not detect repo name.")
38+
return repo_name
39+
except subprocess.CalledProcessError:
40+
print("Error: Unable to detect repository name. Ensure you're in a Git repository.")
41+
return None
42+
43+
# Use the dynamic repo name
44+
REPO_NAME = get_repo_name()
45+
1346

1447
# Hardcoded repository name
15-
REPO_NAME = "RedNeckSnailSpit/IssueAutomationTest"
48+
# REPO_NAME = "RedNeckSnailSpit/IssueAutomationTest"
1649

1750
# Path to the config file
1851
CONFIG_FILE = "config.json"
@@ -163,6 +196,9 @@ def simulate_and_report_exception():
163196
if __name__ == "__main__":
164197
setup()
165198
config = load_config()
199+
200+
print(f"Repo Name: {REPO_NAME}")
201+
166202
GITHUB_TOKEN = config.get("github_token")
167203
if GITHUB_TOKEN is None:
168204
print("GitHub token not found in config.json. Please run the setup process.")

0 commit comments

Comments
 (0)