forked from AFPy/potodo
Fix #37
This commit is contained in:
parent
6c4db80b6e
commit
008489d391
|
@ -1,21 +1,26 @@
|
||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from typing import Mapping
|
from typing import Mapping
|
||||||
from subprocess import check_output
|
|
||||||
|
|
||||||
|
|
||||||
def get_repo_url(repo_path: str) -> str:
|
def get_repo_url(repo_path: str) -> str:
|
||||||
"""Tries to get the repository url from git commands
|
"""Tries to get the repository url from git commands
|
||||||
"""
|
"""
|
||||||
url = check_output("git remote get-url --all upstream".split(), universal_newlines=True, cwd=repo_path)
|
try:
|
||||||
if "fatal" in url:
|
url = subprocess.check_output("git remote get-url --all upstream".split(),
|
||||||
url = check_output("git remote get-url --all upstream".split(), universal_newlines=True, cwd=repo_path)
|
universal_newlines=True, cwd=repo_path,
|
||||||
if "fatal" in url:
|
stderr=subprocess.STDOUT)
|
||||||
# If the commands didn't work
|
except subprocess.CalledProcessError:
|
||||||
raise RuntimeError(
|
try:
|
||||||
f"Unknown error. `git get-url --all upstream|origin` returned {url}"
|
url = subprocess.check_output("git remote get-url --all origin".split(),
|
||||||
)
|
universal_newlines=True, cwd=repo_path,
|
||||||
|
stderr=subprocess.STDOUT)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
raise RuntimeError(
|
||||||
|
f"Unknown error. `git get-url --all upstream|origin` returned \"{e.output.rstrip()}\"."
|
||||||
|
)
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user