From 3370f48c2b869dbf59e3dc3d78751442a844067c Mon Sep 17 00:00:00 2001 From: Brian Pugh Date: Fri, 17 Feb 2023 18:28:30 -0800 Subject: [PATCH] fix git checking out branch/commits --- belay/packagemanager/downloaders/_github.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/belay/packagemanager/downloaders/_github.py b/belay/packagemanager/downloaders/_github.py index 205143e..4625f3c 100644 --- a/belay/packagemanager/downloaders/_github.py +++ b/belay/packagemanager/downloaders/_github.py @@ -46,15 +46,12 @@ def github(dst: Path, uri: str): if (repo_folder / ".git").is_dir(): # Already been cloned repo = git.Repo(repo_folder) - origin = repo.remote("origin") - origin.fetch() + repo.remotes.origin.pull() else: repo = git.Repo.clone_from(repo_url, repo_folder) - # Set to specified reference - commit = repo.rev_parse(ref) - repo.head.reference = commit - repo.head.reset(index=True, working_tree=True) + repo.git.clean("-xdf") + repo.git.checkout(ref) shutil.copytree(repo_folder / path, dst, dirs_exist_ok=True) else: