#!/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. sessionStorage 前端HTML5会话管理

    sessionStorage 是在HTML5中新增的一个会话存储对象,sessionStorage 用于临时保存同一窗口(或标签页)的数据,在关闭窗口或标签页之后将会删除这些数据.. 提示: 如果你想 ...

  2. webpack入门操作教程

    1. webpack介绍 在传统的项目中,一个html文件可能会加载多个js.css文件,如果多人协同开发的话,就会出现全局变量被污染.文件直接的依赖问题 而webpack打包工具,会先分析入口文件的 ...

  3. 于用cocoapods添加第三方库,并且cocoapods添加成功,但是却在任何一个文件上都导入不了头文件

    关于用cocoapods添加第三方库,并且cocoapods添加成功,但是却在任何一个文件上都导入不了头文件,而且根本没有提示,即使手动打#import "xxxx.h"也报错xx ...

  4. 007-chrome插件系列

    1.Axure RP Extension for Chrome 2.Charset 3.CLEAN crxMouse Gestures 4.Google 翻译 5.JSONView 6.restlet

  5. selenium--键盘事件

    from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.Fi ...

  6. FG面经Prepare: BST to Double LinkedList

    BST to double linkedlist in inorder traversal sequenceFollow Up: 如果这个BST自带prev, next, 给一个value,插进去这个 ...

  7. Java设计模式之动态代理

    关于Proxy: 1,他是所有动态代理的父类: 2,他可以用作创建动态代理类和动态代理对象: 3,JDK中自带的动态代理. 1,首先创建一个接口,方法申明如下: package com.proxy; ...

  8. Openstack oslo.config【一】

    OpenStack的项目貌似越来越多了,在Grizzly版之前,每个项目都得实现一套处理配置文件的代码.在每个项目的源码中基本上都可以找到openstack/common/cfg.py,inipars ...

  9. rpgmakermv \c 常用颜色一览

    1 2 3 4 5 6 7 14 18

  10. laravel composer

    composer config -g repo.packagist composer https://packagist.phpcomposer.com 改安装包的全局镜像网址