hch
2018-08-28 d564d4191b1821f62962077ae79c593dfe8d574b
add:添加钩子和更新脚本
3个文件已添加
115 ■■■■■ 已修改文件
Hooks/commit-msg 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hooks/commit-msg.meta 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pull_git.sh 95 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hooks/commit-msg
New file
@@ -0,0 +1,12 @@
#!/bin/sh
# -*- coding: UTF-8 -*-
if [ "$(grep -in '^[0-9]*[1-9][0-9]* .*' "$1")" == "" ] && [ "$(grep -in '^Merge .*' "$1")" == "" ] && [ "$(grep -in '^Revert .*' "$1")" == "" ]; then
    echo 以下3种是正确的备注信息是:
    echo 1. 12345 正常提交备注信息必须以数字单号开头。#数字单号后面带空格#
    echo 2. Merge 以Merge开头说明这是一次git合并操作,这是被允许的。#Merge后面带空格#
    echo 3. Revert 以Revert开头说明这是一次git还原操作,这是被允许的。#Revert后面带空格#
    exit 1
fi
Hooks/commit-msg.meta
New file
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b87aef1931a05ca49890a8fc42649dfb
timeCreated: 1535439812
licenseType: Pro
DefaultImporter:
  userData:
  assetBundleName:
  assetBundleVariant:
pull_git.sh
New file
@@ -0,0 +1,95 @@
#!/bin/sh
Branch=master
Tag=""
# 客户端根路径
client_path="./"
# 开关 【0】不拉取 【1】冲突不拉取 【2】强拉、覆盖
client=2
# 标签
t_client=$Tag
# 路径配置
# 远程Git
g_client="http://admin@192.168.0.87:10010/r/snxx_server.git"
# 无则创建;且拉取最新
# $1 路径
# $2 git地址
# $3 标签
cloneAll() {
    if [ $1 = 0 ]; then return; fi
    echo
    echo "===================="
    echo "path:"$2
    echo "git:"$3
    echo "tag:"$4
    echo "===================="
    # 不存在路径就创建
    if [ ! -d $2 ];then
        echo "第一次创建"
        git clone $3 $2
    fi
    # 拉取
    cd $2
    git stash
    git pull --progress -f
    # 无标签
    if [ -z $4 ];then
        if [ $1 = 2 ];then
            git checkout -B $Branch origin/${Branch} -f
        else
            git checkout -B $Branch origin/${Branch}
        fi
    else
        #删本地标签
        git tag -d $4
        git pull --progress -f
        #切分支
        git checkout -B $Branch origin/${Branch} -f
        #切标签
        git reset $4 --hard
    fi
}
copyHooks() {
    if [ $1 = 0 ]; then return; fi
    echo $1
    root=$1
    echo root
    fileFrom=${root}"/Hooks/commit-msg"
    fileTo=${root}"/.git/hooks/commit-msg"
    echo $fileFrom
    echo $fileTo
    cp $fileFrom $fileTo
}
# client 一定要拉取
if [ ! -d ${client_path} ]; then mkdir ${client_path}; fi
if [ "`ls -A $client_path`" = "" ]; then rm -rf $client_path; fi
cloneAll $client $client_path $g_client $t_client
copyHooks $client_path
echo
read -p "操作完成,点Enter键退出"