一键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 ...
随机推荐
- rpc轻量级框架实例
- webapi发布到windows 2012的iis8里 出错
HTTP 错误 403.14 - Forbidden Web 服务器被配置为不列出此目录的内容. 选一个.net版本一致的应用程序池 即可
- 三目运算符与Scanner类
1.三目运算符(条件运算符)格式:X ? Y : ZX表达式必须是boolean类型 的表达式执行流程:首先计算X表达式的结果,如果X的结果为true,那么整个表达式的结果就是Y的值如果X的结果为tr ...
- Hadoop组件
---------Hive--------------------------zooKeeper-------------------------------kafka---------------- ...
- java支付宝接口开发
在线支付接入支付宝,首先需要去官网申请开发者账号,具体步骤如下: 一.打开官网 1.直接打开链接https://open.alipay.com/platform/home.htm进入 2.百度搜索蚂蚁 ...
- PHP多维数组替换某一元素的值
数组结构如下所示: $arr = [ [ 'id' => 1, 'sub'=> [ [ 'value' => 11.2 ], [ 'value' => 34.5 ] ] ], ...
- winrar目录穿越漏洞
地址: 参考: https://research.checkpoint.com/extracting-code-execution-from-winrar/ POC: https://github.c ...
- Beyond Compare相同文件为何显示差异
原文地址: http://www.beyondcompare.cc/wenti/wenjian-chayi.html Beyond Compare是一款经典老牌且优秀的专业级文本比较工具,它可以很方便 ...
- set nocount on/off的作用,可配合存储过程使用
当set nocount 为NO的时候,不返回计数(受Transact-SQL语句影响行数) 当set nocount 为OFF时,返回计数(默认返回) 当 SET NOCOUNT 为 ON 时,将不 ...
- dotnetcore ef 调用多个数据库时用户命令执行操作报错
dotnetcore ef 调用多个数据库时用户命令执行操作报错 1.多个DbContext 时报错: 报错: More than one DbContext was found. Specify w ...