From d564d4191b1821f62962077ae79c593dfe8d574b Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期二, 28 八月 2018 16:16:23 +0800
Subject: [PATCH] add:添加钩子和更新脚本

---
 Hooks/commit-msg.meta |    8 ++++
 pull_git.sh           |   95 +++++++++++++++++++++++++++++++++++++++++++++++
 Hooks/commit-msg      |   12 ++++++
 3 files changed, 115 insertions(+), 0 deletions(-)

diff --git a/Hooks/commit-msg b/Hooks/commit-msg
new file mode 100644
index 0000000..ceee404
--- /dev/null
+++ b/Hooks/commit-msg
@@ -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绉嶆槸姝g‘鐨勫娉ㄤ俊鎭槸锛�
+	echo 1. 12345 姝e父鎻愪氦澶囨敞淇℃伅蹇呴』浠ユ暟瀛楀崟鍙峰紑澶淬��#鏁板瓧鍗曞彿鍚庨潰甯︾┖鏍�#
+	echo 2. Merge 浠erge寮�澶磋鏄庤繖鏄竴娆it鍚堝苟鎿嶄綔锛岃繖鏄鍏佽鐨勩��#Merge鍚庨潰甯︾┖鏍�#
+	echo 3. Revert 浠evert寮�澶磋鏄庤繖鏄竴娆it杩樺師鎿嶄綔锛岃繖鏄鍏佽鐨勩��#Revert鍚庨潰甯︾┖鏍�#
+	exit 1
+
+fi
+
diff --git a/Hooks/commit-msg.meta b/Hooks/commit-msg.meta
new file mode 100644
index 0000000..1cd01f3
--- /dev/null
+++ b/Hooks/commit-msg.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: b87aef1931a05ca49890a8fc42649dfb
+timeCreated: 1535439812
+licenseType: Pro
+DefaultImporter:
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/pull_git.sh b/pull_git.sh
new file mode 100644
index 0000000..f0e572b
--- /dev/null
+++ b/pull_git.sh
@@ -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閿��鍑�"
\ No newline at end of file

--
Gitblit v1.8.0