gerrit_bash_commands.sh
https://github.com/tomwys/gerrit-bash-commands
gerrit_bash_commands.sh
# Author: Tomasz Wysocki <tomasz@wysocki.info>
function workonbranch {
if [ "$1" = "" ]
then
echo "Usage: workonbranch [branch name]"
return
fi
if [ "$CURRENT_BRANCH" != "" ]
then
deactivatebranch
fi
_WORKONBRANCH_OLD_PS1="$PS1"
CURRENT_BRANCH="$1"
PS1="[$CURRENT_BRANCH]$PS1"
} function deactivatebranch {
_branch_check_if_active || return PS1="$_WORKONBRANCH_OLD_PS1"
unset CURRENT_BRANCH
} function _branch_check_if_active {
if [ "$CURRENT_BRANCH" = "" ]
then
echo "No branch activated"
return
fi
return
} function branch_push_for {
OPTIND=
RECIVE_PACK='git receive-pack'
while getopts "r:" O; do
case "$O" in
r)
RECIVE_PACK="$RECIVE_PACK --reviewer $OPTARG"
;;
c)
RECIVE_PACK="$RECIVE_PACK --cc $OPTARG"
;;
esac
done;
shift $((OPTIND-));
_branch_check_if_active || return
git push --receive-pack="$RECIVE_PACK" origin "HEAD:refs/for/$CURRENT_BRANCH" $@
} function branch_push_heads {
_branch_check_if_active || return
git push origin "HEAD:refs/heads/$CURRENT_BRANCH" $@
} function branch_push_drafts {
_branch_check_if_active || return
git push origin "HEAD:refs/drafts/$CURRENT_BRANCH" $@
} function branch_checkout {
if [ "$1" != "" ]
then
workonbranch $
fi
_branch_check_if_active || return
git fetch -p && git checkout "origin/$CURRENT_BRANCH"
} function close_branch {
if [ "$1" = "" ]
then
echo "close_branch [branch name]"
exit
fi
branch_checkout master && git merge origin/$ --no-ff && branch_push_heads && git push origin :refs/heads/$
} _complete_branch() {
# bash-completion for branch name
# based on: http://devmanual.gentoo.org/tasks-reference/completion/index.html
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts=$(git branch -r| grep origin | grep -v HEAD | sed 's/ origin\///') if [[ ${cur} == -* || ${COMP_CWORD} -eq ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return
fi
}
_complete_user() {
# bash-completion for git user
# based on: http://devmanual.gentoo.org/tasks-reference/completion/index.html
local cur prev opts
COMPREPLY=()
prev="${COMP_WORDS[$COMP_CWORD-1]}"
cur="${COMP_WORDS[$COMP_CWORD]}" if [ "$prev" = "-r" -o "$prev" = "-c" ] ; then
opts=$(git log --pretty=format:'%ae' | sort | uniq)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return
fi
}
complete -F _complete_branch workonbranch
complete -F _complete_branch branch_checkout
complete -F _complete_branch close_branch
complete -F _complete_user branch_push_for
gerrit_bash_commands.sh的更多相关文章
- 数据库备份并分离日志表(按月)sh 脚本
#!/bin/sh year=`date +%Y` month=`date +%m` day=`date +%d` hour=`date +%H` dir="/data/dbbackup/f ...
- Linux下如何查找.sh后缀的文件
find / -name *.sh或locate *.shfind 与locate的区别:locate 配合数据库查看文件位置 find 实际搜寻硬盘查询文件名称
- sh 测试网段在线主机
yum install nmap nmap -sP 192.168.21.1/24 查看网段在线主机 grep -vwf file1 file2 文件内容比较 #!/bin/bash # day=` ...
- Maven打包生成可运行bat/sh脚本文件
利用Maven的appassembler-maven-plugin插件,就可以实现自动打包可运行的脚本,还可以跨平台. <plugin> <groupId>org ...
- 记一个简单的保护if 的sh脚本
真是坑爹,就下面的sh,竟然也写了很久! if [ `pwd` != '/usr/xx/bin/tomcat' ] then echo "rstall is not allowed in c ...
- 主机巡检脚本:OSWatcher.sh
主机巡检脚本:OSWatcher.sh 2016-09-26更新,目前该脚本只支持Linux操作系统,后续有需求可以继续完善. 注意: 经测试,普通用户执行脚本可以顺利执行前9项检查: 第10项,普通 ...
- Oracle巡检脚本:ORAWatcher.sh
Oracle巡检脚本:ORAWatcher.sh #!/usr/bin/ksh echo "" echo "ORAWatcher Version:1.0.1" ...
- 解决:/bin/sh: 1: /home/**/custom_app.sh: Permission denied错误
出现如下错误,一般是执行权限不够. /bin/sh: : /home/custom_app.sh: Permission denied 解决方法是:cd 到此文件目录,对提示的文件赋予可执行权限或读写 ...
- SH Script Grammar
http://linux.about.com/library/cmd/blcmdl1_sh.htm http://pubs.opengroup.org/onlinepubs/9699919799/ut ...
随机推荐
- Kafka 之 入门
摘要: 最近研究采集层,对Kafka做了一个研究.分为入门,中级,高级步步进阶.本篇主要介绍基本概念,适用场景. 一.入门 1. 简介 Kafka is a distributed, parti ...
- 每天一个linux命令:Linux 目录结构
对于每一个Linux学习者来说,了解Linux文件系统的目录结构,是学好Linux的至关重要的一步.,深入了解linux文件目录结构的标准和每个目录的详细功能,对于我们用好linux系统至关只要,下面 ...
- cordova ios and ios8
ios8发布后,一些用cordova编写的app会碰到问题,总的来说,cordova官方称是完全支持ios8的,而且由于ios8推出的WKWebView存在问题并没能很好的解决(看原文),仍旧用了UI ...
- 【spark】with mongodb
https://docs.mongodb.com/spark-connector/master/python-api/
- Android开发中常用的库总结(持续更新)
这篇文章用来收集Android开发中常用的库,都是实际使用过的.持续更新... 1.消息提示的小红点 微信,微博消息提示的小红点. 开源库地址:https://github.com/stefanjau ...
- Node.js之exports与module.exports
每一个node.js执行文件,都自动创建一个module对象,同时,module对象会创建一个叫exports的属性,初始化的值是 {} module.exports = {}; Node.js为了方 ...
- Unity对象池管理
链接: http://www.xuanyusong.com/archives/2925 http://www.xuanyusong.com/archives/2974 https://www.cnbl ...
- PHP 数组current和next用法
1.current 当前数组 <?php $transport = array('foot', 'bike', 'car', 'plane'); $mode = current($trans ...
- 跨域、跨服务器调用时候session丢失的问题
最近新进一个公司,做的项目是手机支付系统.由于涉及到金钱相关的,所以安全性要求特别的高.项目分了很多个子系统,在部署(测试)的时候是每个Tomcat上面只放一个子系统.比如现在有5个子系统,那么就会对 ...
- 纯CSS实现瀑布流布局
https://www.w3cplus.com/css/pure-css-create-masonry-layout.html