Browse Source

update_git_pull_checkout_en

liushuai 2 months ago
parent
commit
a16b8e8fb8
3 changed files with 15 additions and 8 deletions
  1. 4 1
      preset/app/checkout.py
  2. 6 5
      preset/app/git.py
  3. 5 2
      preset/app/pull.py

+ 4 - 1
preset/app/checkout.py

@@ -1,4 +1,5 @@
 localrep = "/home/backup"
 localrep = "/home/backup"
+remoteurl = 'https://git.cocorobo.cn/liushuai/CocoPi_upgrade.git'
 otaPath = "/root/preset/app/ota.py"
 otaPath = "/root/preset/app/ota.py"
 
 
 from maix import camera, display, image
 from maix import camera, display, image
@@ -21,6 +22,8 @@ class NewStream(RawIOBase):
 
 
 
 
 git.rw()
 git.rw()
+
+git.swRemote(localrep, remoteurl)
 steam = NewStream()
 steam = NewStream()
 
 
 if git.activeBranch(localrep) != b'zh':
 if git.activeBranch(localrep) != b'zh':
@@ -36,4 +39,4 @@ with open(otaPath) as f:
     code = f.read()
     code = f.read()
 exec(code)
 exec(code)
 
 
-git.ro()
+git.ro()

+ 6 - 5
preset/app/git.py

@@ -119,13 +119,14 @@ def isOnline(localRep):
     
     
 def swRemote(localRep, remote_url):
 def swRemote(localRep, remote_url):
     r = Repo(localRep)
     r = Repo(localRep)
-    porcelain.remote_remove(r,'origin')
-    porcelain.remote_add(r,'origin',remote_url)
+    try:
+        porcelain.remote_remove(r,'origin')
+        porcelain.remote_add(r,'origin',remote_url)
+    except:
+        porcelain.remote_add(r,'origin',remote_url)
 
 
 def swRemote_force(localRep, remote_url):
 def swRemote_force(localRep, remote_url):
-    r = Repo(localRep)
-    porcelain.remote_remove(r,'origin')
-    porcelain.remote_add(r,'origin',remote_url)
+    swRemote(localRep, remote_url)
     porcelain.fetch(localRep)
     porcelain.fetch(localRep)
     porcelain.pull(localRep, refspecs=porcelain.active_branch(localRep), force=True)
     porcelain.pull(localRep, refspecs=porcelain.active_branch(localRep), force=True)
 
 

+ 5 - 2
preset/app/pull.py

@@ -1,5 +1,6 @@
 localrep = "/home/backup"
 localrep = "/home/backup"
-otaPath = 'ota.py'
+remoteurl = 'https://git.cocorobo.cn/liushuai/CocoPi_upgrade.git'
+otaPath = "/root/preset/app/ota.py"
 
 
 from maix import camera, display, image  # 引入python模块包
 from maix import camera, display, image  # 引入python模块包
 
 
@@ -29,6 +30,8 @@ class NewStream(RawIOBase):
 
 
 
 
 git.rw()
 git.rw()
+
+git.swRemote(localrep, remoteurl)
 steam = NewStream()
 steam = NewStream()
 git.pull(localrep, steam)
 git.pull(localrep, steam)
 
 
@@ -44,4 +47,4 @@ with open(otaPath) as f:
     code = f.read()
     code = f.read()
 exec(code)
 exec(code)
 
 
-git.ro()
+git.ro()