Properly retrieve repo details for each source

This commit is contained in:
Waqar Ahmed
2021-04-13 16:52:14 +05:00
committed by Waqar Ahmed
parent 5fda5463dd
commit d3e7b1f482
3 changed files with 7 additions and 7 deletions

View File

@@ -5,17 +5,17 @@ from .variables import GIT_MANIFEST_PATH
# TODO: Let's please use python for git specific bits
def update_git_manifest(git_remote, git_sha):
with open(GIT_MANIFEST_PATH, 'a+') as f:
def update_git_manifest(git_remote, git_sha, mode='a+'):
with open(GIT_MANIFEST_PATH, mode) as f:
f.write(f'{git_remote} {git_sha}\n')
def retrieve_git_remote_and_sha(path):
return {
'url': run(['git', '-C', path, 'remote', 'get-url', 'origin']).stdout.decode(),
'sha': run(['git', '-C', path, 'rev-parse', '--short', 'HEAD']).stdout.decode(),
'url': run(['git', '-C', path, 'remote', 'get-url', 'origin']).stdout.decode().strip(),
'sha': run(['git', '-C', path, 'rev-parse', '--short', 'HEAD']).stdout.decode().strip(),
}
def retrieve_git_branch(path):
return run(['git', '-C', path, 'branch', '--show-current']).stdout.decode()
return run(['git', '-C', path, 'branch', '--show-current']).stdout.decode().strip()