Jelajahi Sumber

增加了强制推送的功能

Huan 5 tahun lalu
induk
melakukan
f45d821e93
2 mengubah file dengan 8 tambahan dan 7 penghapusan
  1. 2 1
      GIT.py
  2. 6 6
      Git_Ctrl.py

+ 2 - 1
GIT.py

@@ -355,7 +355,8 @@ def Pull_Push_remote(type_):
     Local = LocalBranch.get()
     allow = bool(allow_history.get())
     u = bool(push_bind.get())
-    do_Sys({0:Git.Pull_remote,1:Git.Push_remote}.get(type_,Git.Pull_remote), (get_Name(), Local, Remote, Branch, allow, u),
+    f = tkinter.messagebox.askokcancel('提示', f'是否需要强制推送?(强制推送不被建议)')
+    do_Sys({0:Git.Pull_remote,1:Git.Push_remote}.get(type_,Git.Pull_remote), (get_Name(), Local, Remote, Branch, allow, u, f),
            break_time=0,text_n=f'此操作需要连接远程仓库,请稍等...',th=True,wait=True)
     update_Git_Dir()
 

+ 6 - 6
Git_Ctrl.py

@@ -173,7 +173,7 @@ class git_Repo:#git的基类
     def show_new(self,condition):
         return subprocess.Popen(f'echo 查询结果: && {git_path} show {condition} && echo {self.make_stopKey()}', cwd=self.Repo_Dic, **sys_seeting)
 
-    def Pull_Push_remote(self,Pull_Push=0,remote='',remote_branch='',local='',allow=False,u=False):
+    def Pull_Push_remote(self,Pull_Push=0,remote='',remote_branch='',local='',allow=False,u=False,f=False):
         #处理逻辑
         # 1)remote去斜杠第一个作为主机名字
         # 2) 从remote分离主机名(如果没指定)
@@ -206,7 +206,7 @@ class git_Repo:#git的基类
             history = ' --allow-unrelated-histories'
         else:
             history = ''
-        push_pull = {0:"pull",1:f"push{' -u' if u else ''}"}
+        push_pull = {0:"pull",1:f"push{' -u' if u else ''}{' -f' if f else ''}"}
         return subprocess.Popen(f'''echo 与服务器连接... && {git_path} {push_pull.get(Pull_Push,"pull")}{history} {remote_name} {branch} && echo {self.make_stopKey()}''',
                                 cwd=self.Repo_Dic, **sys_seeting)
 
@@ -373,11 +373,11 @@ class git_Ctrol:
     def Bind_remote(self,name,local_name,remote_name):
         return self.get_git(name).Bind_remote(local_name,remote_name)
 
-    def Pull_remote(self,name,local_name,remote_name,remote_branch,allow=False,u=False):
-        return self.get_git(name).Pull_Push_remote(0,remote_name,remote_branch,local_name,allow,u)
+    def Pull_remote(self,name,local_name,remote_name,remote_branch,allow=False,u=False,f=False):
+        return self.get_git(name).Pull_Push_remote(0,remote_name,remote_branch,local_name,allow,u,False)
 
-    def Push_remote(self,name,local_name,remote_name,remote_branch,allow=False,u=False):
-        return self.get_git(name).Pull_Push_remote(1,remote_name,remote_branch,local_name,False,u)#push没有allow选项
+    def Push_remote(self,name,local_name,remote_name,remote_branch,allow=False,u=False,f=False):
+        return self.get_git(name).Pull_Push_remote(1,remote_name,remote_branch,local_name,False,u,f)#push没有allow选项
 
     def Tag(self,name, condition=''):
         return self.get_git(name).Tag(condition)  # push没有allow选项