# import svn.local # client = svn.local.LocalClient("E:/code/svn/svn_client/client_1") # # for commit in client.log_default(limit=20): # # revision = commit.revision # # date = commit.date # # print("{}:{}".format(date, revision)) # client.add("E:/code/svn/svn_client/client_1/sasasas/一万年.txt") # client.update() # client.commit("sasas") # 从远处仓库下载代码到本地 import os import subprocess import sys from ctypes import Union from sre_constants import BRANCH from git.repo import Repo # 创建本地存储地址 download_path = os.path.join('jason','NB') # 从远程仓库下载代码 # new_repo = Repo.clone_from('http://192.168.4.210/liaoyourong/qiuqiugitTest.git',to_path=download_path,branch='master') # repo = Repo(download_path) # repo.index.add(items = ['13155.xlsx']) # repo.index.commit('lalala') # new_repo = Repo.init(download_path) # new_repo.index.add(items = ['13155.xlsx']) # new_repo.index.commit('lalala') addstr = "." branch = "master" GitStatusCommand = "git status -s" GitPullCommand = "git pull" GitAddCommand = "git add " + addstr GitCommitCommand = 'git commit -m "' + "commit" + '"' GitPushCommand = "git push origin " + branch SVNUpdateCommand = "svn update" SVNAddCommand = "svn add ." SVNCommitCommand = 'svn commit -m "test"' def run_command(command: str): # print(command) process = subprocess.Popen(command.split(), stdout=subprocess.PIPE) # print(str(process.args)) # if command.startswith("git push"): # output, error = process.communicate() # else: # output, error = process.communicate() # try: # output = bytes(output).decode() # error = bytes(error).decode() # if not output: # print("output: " + output) # print("error: " + error) # except TypeError: # print() output, error = process.communicate() os.chdir("/jason/client_4") # # git更新提交 # run_command(GitStatusCommand) # run_command(GitPullCommand) # run_command(GitAddCommand) # run_command(GitCommitCommand) # run_command(GitPushCommand) # # svn更新提交 # run_command(SVNUpdateCommand) run_command(SVNAddCommand) # run_command(SVNCommitCommand) # os.chdir("/jason/client_4") # git更新提交 # run_command(GitPullCommand) # run_command(GitAddCommand) # run_command(GitCommitCommand) # run_command(GitPushCommand) # # svn更新提交 # run_command(SVNUpdateCommand) # run_command(SVNAddCommand) # run_command(SVNCommitCommand)