一键git push脚本(python版)
#!/usr/bin/env python
import os
import subprocess
import sys
import time
gitconfig = {
'cwd': './blog/public',
'git': {
'github': ['git@github.com:akkuman/akkuman.github.io.git', 'master'],
'coding': ['git@git.coding.net:Akkuman/Akkuman.git', 'coding-pages'],
}
}
def main():
global gitconfig
# change working directory
os.chdir(gitconfig.get('cwd', '.'))
# check if git init
if '.git' not in os.listdir():
subprocess.check_call(['git', 'init'])
# check if remote in config, if not, add the remote
git_remotes = subprocess.check_output(['git', 'remote', '-v'])
git_remotes_str = bytes.decode(git_remotes).strip()
git_remotes_list = [line.split()[0] for line in git_remotes_str.split('\n')]
for k,v in gitconfig['git'].items():
if k not in git_remotes_list:
subprocess.check_call(['git', 'remote', 'add', k, v[0]])
# add . & commit with message
subprocess.check_call(['git', 'add', '.'])
commit_message = 'Site updated: %s' % time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
if len(sys.argv) == 2:
commit_message = sys.argv[1]
subprocess.call(['git', 'commit', '-m', commit_message])
# push to every remote repo
for k,v in gitconfig['git'].items():
subprocess.check_call(['git', 'push', k, 'master:%s' % v[1]])
if __name__ == '__main__':
if len(sys.argv) == 2:
if sys.argv[1] == '-h':
print('Usage:\n\t%s [commit_message]' % sys.argv[0])
main()
一键git push脚本(python版)的更多相关文章
- 简单的处理git add ,git commit,git push 脚本
创建脚本lazygit.sh #!/bin/bash # 一次性处理git提交 #branch_name=`git symbolic-ref --short -q HEAD` branch_name= ...
- *** Python版一键安装脚本
本脚本适用环境:系统支持:CentOS 6,7,Debian,Ubuntu内存要求:≥128M日期:2018 年 02 月 07 日 关于本脚本:一键安装 Python 版 *** 的最新版.友情提示 ...
- LAMP一键安装包(Python版)
去年有出一个python整的LAMP自动安装,不过比较傻,直接调用的yum 去安装了XXX...不过这次一样有用shell..我也想如何不调用shell 来弄一个LAMP自动安装部署啥啥的..不过尼玛 ...
- jenkins在windows服务器上执行含git push命令的脚本权限不足的解决方法
错误摘要 默认情况下执行脚本是没问题的,但是脚本中含有git push命令就无法执行了 用jenkins部署hexo博客时候遇到的,执行hexo d -g一直阻塞至Build was aborted, ...
- 大喜python版opencv3发布,demo脚本抢鲜版发布
大喜,python版opencv3发布 zwPython3的升级也可以启动了,一直在等这个,zwPython会直接升级到版本3:zwPython3 zwPython3采用64位python3,支持op ...
- 移动端自动化测试Appium 从入门到项目实战Python版☝☝☝
移动端自动化测试Appium 从入门到项目实战Python版 (一个人学习或许会很枯燥,但是寻找更多志同道合的朋友一起,学习将会变得更加有意义✌✌) 说到APP自动化测试,Appium可是说是非常流 ...
- 【原】Learning Spark (Python版) 学习笔记(三)----工作原理、调优与Spark SQL
周末的任务是更新Learning Spark系列第三篇,以为自己写不完了,但为了改正拖延症,还是得完成给自己定的任务啊 = =.这三章主要讲Spark的运行过程(本地+集群),性能调优以及Spark ...
- git push如何至两个git仓库
分别有仓库 A(github),B(JAE 的 git),本机为C. 假设以 a 仓库作为最终的使用仓库, b为发布仓库.分支都为 dev 第一步,增加远程仓库 git remote add orig ...
- CentOS 6一键系统优化 Shell 脚本
CentOS 6一键系统优化 Shell 脚本 脚本的内容如下: #!/bin/bash#author suzezhi#this script is only for CentOS 6#check t ...
随机推荐
- .net js有数据 但是跳转不到操作页
首先看的是:js 的 model 传了 两个参数 在接着打开操作页 可以看到,这一页有三个参数.id是可以自动生成的,所以不让他显示,去掉 如上就可以了 ,传的参数数量不对 ,下次注意的撒!
- js中类似null==flase的比较图集
以上是比较全的图集了,大家可以自行测试.
- chrome浏览器多开的方法
Chrome浏览器在上网的过程中,会保存一些用户数据,如缓存.cookie.收藏的网页等信息. 这些信息的保存位置是可以设置的.方法也很简单: 桌面上复制一个Chrome的快捷方式,编辑属性,添加-- ...
- #WEB安全基础 : HTTP协议 | 0x14 HTTP的详细安全问题
我们提到过HTTP是不安全的. 由于任何人都可以向服务器发送请求,而并不会验证身份,所以这就会引发一些问题: 1,发出响应的服务器是否为正确的服务器 2,发送请求的客户端是否为正确的客户端 3,通信双 ...
- JDBC事务的相关知识
事务的定义 事务(Transaction):是并发控制的单元,是用户定义的一个操作序列.这些操作要么都做,要么都不做,是一个不可分割的工作单位.通过事务,sql server 能将逻辑相关的一组操作绑 ...
- 自动化运维工具——ansile详解
自动化运维工具——ansible详解(一) 目录 ansible 简介 ansible 是什么? ansible 特点 ansible 架构图 ansible 任务执行 ansible 任务执行模式 ...
- 【Python学习】yield send我就说这么多
C#的yield已经忘得差不多了.又遇到python的yield.iterator def testYield(): print 'yield1' m = yield 1 print 'm =' , ...
- lock 单例模式
单例模式只允许创建一个对象,因此节省内存,加快对象访问速度,因此对象需要被公用的场合适合使用,如多个模块使用同一个数据源连接对象等等 网站的计数器,一般也是采用单例模式实现,否则难以同步 单例模式要素 ...
- setoolkit 制作钓鱼网页
由于是在虚拟机下实验,仅做示范 下载地址 git clone https://github.com/trustedsec/social-engineer-toolkit/ 终端输入setoolkit启 ...
- 【论文速读】Cong_Yao_CVPR2017_EAST_An_Efficient_and_Accurate_Scene_Text_Detector
Cong_Yao_CVPR2017_EAST_An_Efficient_and_Accurate_Scene_Text_Detector 作者和代码 非官方版tensorflow实现 非官方版kera ...