test.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. # import svn.local
  2. # client = svn.local.LocalClient("E:/code/svn/svn_client/client_1")
  3. # # for commit in client.log_default(limit=20):
  4. # # revision = commit.revision
  5. # # date = commit.date
  6. # # print("{}:{}".format(date, revision))
  7. # client.add("E:/code/svn/svn_client/client_1/sasasas/一万年.txt")
  8. # client.update()
  9. # client.commit("sasas")
  10. # 从远处仓库下载代码到本地
  11. import os
  12. import subprocess
  13. import sys
  14. from ctypes import Union
  15. from sre_constants import BRANCH
  16. from git.repo import Repo
  17. # 创建本地存储地址
  18. download_path = os.path.join('jason','NB')
  19. # 从远程仓库下载代码
  20. # new_repo = Repo.clone_from('http://192.168.4.210/liaoyourong/qiuqiugitTest.git',to_path=download_path,branch='master')
  21. # repo = Repo(download_path)
  22. # repo.index.add(items = ['13155.xlsx'])
  23. # repo.index.commit('lalala')
  24. # new_repo = Repo.init(download_path)
  25. # new_repo.index.add(items = ['13155.xlsx'])
  26. # new_repo.index.commit('lalala')
  27. addstr = "."
  28. branch = "master"
  29. GitStatusCommand = "git status -s"
  30. GitPullCommand = "git pull"
  31. GitAddCommand = "git add " + addstr
  32. GitCommitCommand = 'git commit -m "' + "commit" + '"'
  33. GitPushCommand = "git push origin " + branch
  34. SVNUpdateCommand = "svn update"
  35. SVNAddCommand = "svn add ."
  36. SVNCommitCommand = 'svn commit -m "test"'
  37. def run_command(command: str):
  38. # print(command)
  39. process = subprocess.Popen(command.split(), stdout=subprocess.PIPE)
  40. # print(str(process.args))
  41. # if command.startswith("git push"):
  42. # output, error = process.communicate()
  43. # else:
  44. # output, error = process.communicate()
  45. # try:
  46. # output = bytes(output).decode()
  47. # error = bytes(error).decode()
  48. # if not output:
  49. # print("output: " + output)
  50. # print("error: " + error)
  51. # except TypeError:
  52. # print()
  53. output, error = process.communicate()
  54. os.chdir("/jason/client_4")
  55. # # git更新提交
  56. # run_command(GitStatusCommand)
  57. # run_command(GitPullCommand)
  58. # run_command(GitAddCommand)
  59. # run_command(GitCommitCommand)
  60. # run_command(GitPushCommand)
  61. # # svn更新提交
  62. # run_command(SVNUpdateCommand)
  63. run_command(SVNAddCommand)
  64. # run_command(SVNCommitCommand)
  65. # os.chdir("/jason/client_4")
  66. # git更新提交
  67. # run_command(GitPullCommand)
  68. # run_command(GitAddCommand)
  69. # run_command(GitCommitCommand)
  70. # run_command(GitPushCommand)
  71. # # svn更新提交
  72. # run_command(SVNUpdateCommand)
  73. # run_command(SVNAddCommand)
  74. # run_command(SVNCommitCommand)