#!/bin/sh
#检查主干上的提交是否都已合并到分支
function check_error()
{
if [ $? != "0" ];then
echo "$1"
echo "$2"
exit 1
fi
}
function get_branch()
{
git checkout $1
git symbolic-ref HEAD 2>&1 #| sed -e 's,.*/\(.*\),\1,' | grep -v "not a symbolic"
}
function get_tag()
{
git describe 2>&1 | grep -v " tags"
}
if [ $# != 1 ];then
echo "wrong param! sh check_merge.sh branch|tag"
exit 1;
fi
work_dir=`pwd`
git config remote.origin.url
check_error "非git目录" "请检查$work_dir"
echo "分支传入=$1"
if [ "x$1" == "xtag" ];then
echo "step in if"
tag=` get_tag `
else
echo "step in else"
tag=`get_branch`
fi
msg="目录信息`git status`"
[ "x$tag" != "x" ]
check_error "检索分支出错,模式为$1" "$msg"
msg=`git log ${tag}..origin/master --pretty=oneline`
[ "x$msg" == "x" ]
check_error "代码需要merge,分支为$tag,以下的commit没有提交" "$msg"
echo "分支$tag merge检查通过"
git clean -dqxf
暂无讨论,说说你的看法吧