Apply code changes from Thomas
Je confirme que ça marche après avoir mis le token dans ~/.mar/config
.
@patryk l'auto-détection actuelle suppose que le remote est 'origin' . Je propose :
Dans git.py
from pathlib import PurePath
from subprocess import run
def get_remote_name(repository_path: PurePath, branch_name: str) -> str:
"""
Returns the remote associated to a branch
:param repository_path: Path to the git repository
:param branch_name: Name of the branch
:return: name of the remote, assumed to consist of a single word (will fail if remote name contains slashes)
"""
output = run(["git", "rev-parse", "--abbrev-ref", branch_name + "@{u}"], capture_output=True, cwd=repository_path)
return output.stdout.decode("utf-8").strip().split('/')[0]
def get_remote_url(repository_path: PurePath, branch_name: str) -> str:
"""
Returns the remote URL of the repository.
:param repository_path: Path to the git repository
:param branch_name: Name of the branch
:return: URL to the remote repository
"""
remote_name = get_remote_name(repository_path, branch_name)
output = run(["git", "remote", "get-url", remote_name], capture_output=True, cwd=repository_path)
return output.stdout.decode("utf-8").strip()
et dans ci-test.py
def ci_test(args):
console = Console()
if not args.repository_path.exists():
console.print("Invalid repository path. Use path to your MAR repository or '.' if you are already there!")
exit(1)
branch = get_current_branch(args.repository_path)
repo_url = get_remote_url(args.repository_path, branch) if args.url is None else args.url
commit_id = get_current_commit(args.repository_path) if args.commit is None else args.commit
Ça marche à condition que le nom des remote ne soit pas composé (genre a/bc).