#!/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版)的更多相关文章

  1. 简单的处理git add ,git commit,git push 脚本

    创建脚本lazygit.sh #!/bin/bash # 一次性处理git提交 #branch_name=`git symbolic-ref --short -q HEAD` branch_name= ...

  2. *** Python版一键安装脚本

    本脚本适用环境:系统支持:CentOS 6,7,Debian,Ubuntu内存要求:≥128M日期:2018 年 02 月 07 日 关于本脚本:一键安装 Python 版 *** 的最新版.友情提示 ...

  3. LAMP一键安装包(Python版)

    去年有出一个python整的LAMP自动安装,不过比较傻,直接调用的yum 去安装了XXX...不过这次一样有用shell..我也想如何不调用shell 来弄一个LAMP自动安装部署啥啥的..不过尼玛 ...

  4. jenkins在windows服务器上执行含git push命令的脚本权限不足的解决方法

    错误摘要 默认情况下执行脚本是没问题的,但是脚本中含有git push命令就无法执行了 用jenkins部署hexo博客时候遇到的,执行hexo d -g一直阻塞至Build was aborted, ...

  5. 大喜python版opencv3发布,demo脚本抢鲜版发布

    大喜,python版opencv3发布 zwPython3的升级也可以启动了,一直在等这个,zwPython会直接升级到版本3:zwPython3 zwPython3采用64位python3,支持op ...

  6. 移动端自动化测试Appium 从入门到项目实战Python版☝☝☝

    移动端自动化测试Appium 从入门到项目实战Python版 (一个人学习或许会很枯燥,但是寻找更多志同道合的朋友一起,学习将会变得更加有意义✌✌)  说到APP自动化测试,Appium可是说是非常流 ...

  7. 【原】Learning Spark (Python版) 学习笔记(三)----工作原理、调优与Spark SQL

    周末的任务是更新Learning Spark系列第三篇,以为自己写不完了,但为了改正拖延症,还是得完成给自己定的任务啊 = =.这三章主要讲Spark的运行过程(本地+集群),性能调优以及Spark ...

  8. git push如何至两个git仓库

    分别有仓库 A(github),B(JAE 的 git),本机为C. 假设以 a 仓库作为最终的使用仓库, b为发布仓库.分支都为 dev 第一步,增加远程仓库 git remote add orig ...

  9. CentOS 6一键系统优化 Shell 脚本

    CentOS 6一键系统优化 Shell 脚本 脚本的内容如下: #!/bin/bash#author suzezhi#this script is only for CentOS 6#check t ...

随机推荐

  1. oracle更具uuid排序后进行分页

    oracle查询分页.一个demo,可以借用. select a.unid from ( select t.unid,rownum rowno from DEV_REG_CFG_CAMERA t wh ...

  2. 构建react项目失败解决办法

    1.初始化项目,报下方错误 2.解决方法,更新淘宝镜像 npm config set registry https://registry.npm.taobao.org 3.在初始化项目 create- ...

  3. 【jdbc访问数据库获取执行sql转换json】

    Talk is cheap.Show me your code. import java.sql.*; import java.util.HashMap; import java.util.Map; ...

  4. jq中get()和eq()的区别

    一直弄混淆的获取元素的方法,现整理一下: :eq(index) 选择器选取带有指定 index 值的元素. index 值从 0 开始,所有第一个元素的 index 值是 0(不是 1). 如:$(& ...

  5. DS18B20初上电显示85℃问题

    以前用的温度采集都是用的AD,这次改为了DS18B20,看了资料,没有很复杂的部分,重要的就是时序.板子出来后初步测试也能正常读取温度,然而有个问题比较奇怪,就是在板子初上电时读取温度总是显示为+85 ...

  6. 全志A33编译环境搭建

    0x00 环境说明: 所使用的开发板为锐尔威视的插针版A33_Vstar 主机系统为WIN10 1809 x64,并且安装VMware Workstation Pro 下载64位的Ubuntu安装镜像 ...

  7. Object:所有类的超类

    Java中每个类都是由Object类扩展而来 1.equals方法 在Object类中,这个方法用于判断两个对象是否具有相同的引用,然而对于大多数类来说,经常需要检测两个对象状态的相等性. publi ...

  8. object tracking 词汇积累

    1. off-the-shelf adj. 现成的:常备的:成品的 adv. 现成地:无需作重大修改地 commercial off-the-shelf商用现货商规成品商业货架产品供应 off-the ...

  9. codeforces-2

    B.chocolates #include<iostream> #include<algorithm> #include<string.h> long long b ...

  10. sedlauncher.exe

    这个进程很恐怖,屁大点的东西,但会造成磁盘爆满. 首先,这个99%不是病毒,而是win10更新后出现的东西. 关于解释,国内乱七八糟的,我没有搜到,只好在狗哥和微软官网搜了一下. 大多说是 KB402 ...