From 28e50a0afde8e10872d11276233063856f2f3f13 Mon Sep 17 00:00:00 2001 From: Robert-André Mauchin Date: Apr 18 2019 14:08:39 +0000 Subject: Handle import path without Go files at the root --- diff --git a/go2rpm/__main__.py b/go2rpm/__main__.py index 3397688..4e71d63 100644 --- a/go2rpm/__main__.py +++ b/go2rpm/__main__.py @@ -246,7 +246,13 @@ def get_repo_parent_name(goipath): def download(goipath): os.environ['GOPATH'] = CACHEDIR os.environ['GO111MODULE'] = "off" - subprocess.check_output(['go', 'get', '-d', goipath]) + try: + subprocess.check_output(['go', 'get', '-d', goipath], stderr=subprocess.STDOUT) + except subprocess.CalledProcessError as err: + if b'no Go files in' in err.stdout: + subprocess.check_output(['go', 'get', '-d', goipath + '/...'], stderr=subprocess.STDOUT) + else: + raise repo = git.Repo(os.path.join(GIT_CACHEDIR, *get_repo_name(goipath))) repo.git.checkout("master") repo.head.reference = repo.heads.master