From f7c4d7848589090553546d5e898fa04b4be7212a Mon Sep 17 00:00:00 2001 From: Robert-André Mauchin Date: Sep 23 2020 15:43:52 +0000 Subject: Use fetch-reset to origin instead of git pull Signed-off-by: Robert-André Mauchin --- diff --git a/go2rpm/__init__.py b/go2rpm/__init__.py index 4c23789..f700039 100644 --- a/go2rpm/__init__.py +++ b/go2rpm/__init__.py @@ -1,3 +1,3 @@ from . import licensing -__version__ = '1.1' +__version__ = '1.2' diff --git a/go2rpm/__main__.py b/go2rpm/__main__.py index 2cab407..af504e9 100644 --- a/go2rpm/__main__.py +++ b/go2rpm/__main__.py @@ -299,9 +299,10 @@ def download(goipath): print(err.stdout.decode()) sys.exit(1) repo = git.Repo(os.path.join(GIT_CACHEDIR, *get_repo_host(goipath))) - repo.head.reference = repo.heads[0] - repo.head.reset(index=True, working_tree=True) - repo.remotes.origin.pull() + repo.remotes[0].fetch() + repo.git.checkout(repo.heads[0]) + repo.git.clean('-xdf') + repo.git.reset(repo.remotes[0].refs[0], '--hard') def get_version(goipath): @@ -333,9 +334,10 @@ def get_version(goipath): def check_if_version_exists(goipath, version, tag, commit): path = os.path.join(GIT_CACHEDIR, *get_repo_host(goipath)) repo = git.Repo(path) - repo.head.reference = repo.heads[0] - repo.head.reset(index=True, working_tree=True) - repo.remotes.origin.pull() + repo.remotes[0].fetch() + repo.git.checkout(repo.heads[0]) + repo.git.clean('-xdf') + repo.git.reset(repo.remotes[0].refs[0], '--hard') if commit: try: repo.git.checkout(commit) @@ -357,9 +359,10 @@ def check_if_version_exists(goipath, version, tag, commit): def set_repo_version(goipath, version, tag, commit): path = os.path.join(GIT_CACHEDIR, *get_repo_host(goipath)) repo = git.Repo(path) - repo.head.reference = repo.heads[0] - repo.head.reset(index=True, working_tree=True) - repo.remotes.origin.pull() + repo.remotes[0].fetch() + repo.git.checkout(repo.heads[0]) + repo.git.clean('-xdf') + repo.git.reset(repo.remotes[0].refs[0], '--hard') if commit: repo.git.checkout(commit) elif version: