]> git.lizzy.rs Git - cheatdb.git/commitdiff
Use git init/fetch instead of git clone
authorrubenwardy <rw@rubenwardy.com>
Sat, 25 Jan 2020 01:07:39 +0000 (01:07 +0000)
committerrubenwardy <rw@rubenwardy.com>
Sat, 25 Jan 2020 01:07:39 +0000 (01:07 +0000)
app/tasks/importtasks.py

index 21e931e367b847526c4214e35a3d6e571af6450b..5e7085050d3237b2289dc7051daf29becf17af35 100644 (file)
@@ -156,8 +156,14 @@ def cloneRepo(urlstr, ref=None, recursive=False):
                        repo = git.Repo.clone_from(gitUrl, gitDir, \
                                        progress=None, env=None, depth=1, recursive=recursive, kill_after_timeout=15)
                else:
-                       repo = git.Repo.clone_from(gitUrl, gitDir, \
-                                       progress=None, env=None, depth=1, recursive=recursive, kill_after_timeout=15, b=ref)
+                       repo = git.Repo.init(gitDir)
+                       origin = repo.create_remote("origin", url=gitUrl)
+                       assert origin.exists()
+                       origin.fetch()
+
+                       new_head = repo.commit(ref) #repo.create_head("target", ref)
+                       repo.head.reference = new_head
+                       repo.head.reset(index=True, working_tree=True)
 
                return gitDir, repo