刘勇虎的官方网站
网站内容包含大前端、服务器开发、Python开发、iOS开发、Android开发、网站维护等技术文章。专注于分享技术经验,职业心得体会,IT优秀文章与教程创作。
Stay hungry,Stay foolish,Stay young
题记
最近在为公司书写项目的api文档,计划利用码云的wiki管理整个项目,公司自有git作为项目内容依托,这样全员都可参与,而我定期向码云推送就可以了。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/9/25 上午10:52
# @Author : liuyonghu
# @Site : https://www.liuyonghu.com
# @File : autoGitPush.py
# @Software: PyCharm
import subprocess
import time
from tools.sendMessageToDD import sendMessage
def add():
cmd = "git add ."
process = subprocess.Popen(cmd, shell=True)
process.wait()
returnCode = process.returncode
if returnCode != 0:
print(" add returnCode", returnCode)
else:
commit()
commitMessage = ""
def commit():
global commitMessage
commitMessage = time.strftime("%Y/%m/%d %H:%M")
cmd = "git commit -m '{}'".format(commitMessage)
# print("cmd = " + cmd)
process = subprocess.Popen(cmd, shell=True)
process.wait()
push()
def push():
cmd = "git push origin master"
process = subprocess.Popen(cmd, shell=True)
process.wait()
returnCode = process.returncode
if returnCode != 0:
print("push returnCode", returnCode)
else:
sendMessage({
"fileName": "api文档 : \n\n已更新,请注意查看! \n" +"\n更新信息: {}".format(
commitMessage),
"text": time.strftime("%Y/%m/%d %H:%M"),
"error": False
})
add()
注意
代码调用顺序
由此除了项目成员向wiki推送状态无法获取外其他事件基本可以省去很多手动操作。如果大家知道更好的办法欢迎讨论指导