From 69e7b766ebc4d513d83801dcbc79898633eb007c Mon Sep 17 00:00:00 2001 From: Robert-André Mauchin Date: Sep 22 2020 05:38:30 +0000 Subject: Use heads[0] instead of heads.master This is to work with repo who use main or other branches as default. See https://github.blog/2020-07-27-highlights-from-git-2-28/ Signed-off-by: Robert-André Mauchin --- diff --git a/go2rpm/__init__.py b/go2rpm/__init__.py index f9113b9..4c23789 100644 --- a/go2rpm/__init__.py +++ b/go2rpm/__init__.py @@ -1,3 +1,3 @@ from . import licensing -__version__ = '1' +__version__ = '1.1' diff --git a/go2rpm/__main__.py b/go2rpm/__main__.py index d152cff..2cab407 100644 --- a/go2rpm/__main__.py +++ b/go2rpm/__main__.py @@ -299,8 +299,7 @@ def download(goipath): print(err.stdout.decode()) sys.exit(1) repo = git.Repo(os.path.join(GIT_CACHEDIR, *get_repo_host(goipath))) - repo.git.checkout("master") - repo.head.reference = repo.heads.master + repo.head.reference = repo.heads[0] repo.head.reset(index=True, working_tree=True) repo.remotes.origin.pull() @@ -309,7 +308,7 @@ def get_version(goipath): repo = git.Repo(os.path.join(GIT_CACHEDIR, *get_repo_host(goipath))) tags = sorted(repo.tags, key=lambda t: t.commit.committed_datetime) if not len(tags): - commit = str(repo.heads.master.commit) + commit = str(repo.heads[0].commit) version = None tag = None else: @@ -323,9 +322,9 @@ def get_version(goipath): tag_date = datetime.now( timezone.utc) - tags[-1].commit.committed_datetime if (tag_date.days > 365 - and repo.heads.master.commit.count() - tags[-1].commit.count() + and repo.heads[0].commit.count() - tags[-1].commit.count() > 14): - commit = str(repo.heads.master.commit) + commit = str(repo.heads[0].commit) else: commit = None return version, tag, commit @@ -334,8 +333,7 @@ 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.git.checkout("master") - repo.head.reference = repo.heads.master + repo.head.reference = repo.heads[0] repo.head.reset(index=True, working_tree=True) repo.remotes.origin.pull() if commit: @@ -359,7 +357,7 @@ 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.master + repo.head.reference = repo.heads[0] repo.head.reset(index=True, working_tree=True) repo.remotes.origin.pull() if commit: