]> git.lizzy.rs Git - cheatdb.git/commitdiff
Fix broken reference based git import v1.16.5
authorrubenwardy <rw@rubenwardy.com>
Sat, 31 Aug 2019 21:09:19 +0000 (22:09 +0100)
committerrubenwardy <rw@rubenwardy.com>
Sat, 31 Aug 2019 21:09:19 +0000 (22:09 +0100)
Fixes #130

app/tasks/importtasks.py

index 108f1b349e1d53e57723de7c0d2694229a99d86c..a5328adaba366c106657165b14209c3a674097d2 100644 (file)
@@ -299,15 +299,17 @@ def cloneRepo(urlstr, ref=None, recursive=False):
                gitUrl = generateGitURL(urlstr)
                print("Cloning from " + gitUrl)
                repo = git.Repo.clone_from(gitUrl, gitDir, \
-                               progress=None, env=None, depth=1, recursive=recursive, kill_after_timeout=15)
+                               progress=None, env=None, depth=1, recursive=recursive, kill_after_timeout=15, b=ref)
 
-               if ref is not None:
-                       repo.create_head("myhead", ref).checkout()
                return gitDir, repo
+
        except GitCommandError as e:
                # This is needed to stop the backtrace being weird
                err = e.stderr
 
+       except gitdb.exc.BadName as e:
+               err = "Unable to find the reference " + (ref or "?") + "\n" + e.stderr
+
        raise TaskError(err.replace("stderr: ", "") \
                        .replace("Cloning into '" + gitDir + "'...", "") \
                        .strip())