一键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 ...
随机推荐
- spark1.3.x与spark2.x启动executor不同的cpu core分配方式
***这里的executor在worker上分配策略以spreadOut 为例*** 1.3版本关键点: for (app <- waitingApps if app.coresLeft > ...
- 加壳软件-Virbox Protector Standalone
Virbox Protector Standalone 加壳工具 防止代码反编译,更安全,更方便 产品简介 Virbox Protector Standalone提供了强大的代码虚拟化.高级混淆与智能 ...
- Google Colab Free GPU Tutorial【转载】
转自:https://medium.com/deep-learning-turkey/google-colab-free-gpu-tutorial-e113627b9f5d 1.Google Cola ...
- 【Bad Practice】12306 query
- JS 变量和函数提升 全局变量和局部变量
变量提升 1. var a = 10; function test() { a = 100; console.log(a); console.log(this.a); var a; console.l ...
- [LeetCode] 97. Interleaving String_ Hard tag: Dynamic Programming
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. Example 1: Input: s1 = ...
- MySQL数据库常用命令和概念 (1)
一.数据库的创建: 1.创建一个名称为mydb1的数据库 create database mydb1; 2.创建一个使用utf8字符集的mydb2数据库. create database mydb2 ...
- java 写一个JSON解析的工具类
上面是一个标准的json的响应内容截图,第一个红圈”per_page”是一个json对象,我们可以根据”per_page”来找到对应值是3,而第二个红圈“data”是一个JSON数组,而不是对象,不能 ...
- 拼多多(7pdd)微信跳转h5页面打开app跳转任意url关注技术weixin://dl/business/?ticket
拼多多微信跳转接口利用了微信官方的weixin://dl/business/?ticket技术,此类接口可以在官方接口中找到,分析代码如下: <title>拼多多</title> ...
- SQL 一列数据整合为一条数据
SQL 一列数据整合为一条数据: SELECT STUFF(( SELECT distinct ',' + 列名 FROM 表名 where [条件] FOR XML PATH('') ), 1 ...