From c45850eb8aaad43a8f5043c24aabf6fb53965e31 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 18 Mar 2015 14:42:11 +0800 Subject: [PATCH] =?UTF-8?q?git=20hook=E6=94=B9=E4=B8=BA=E5=BC=82=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 19 ++++++++++++------- lib/tasks/git_post_update.rake | 20 ++++++++++++-------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 83cfa1e1a..6c115fc11 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -94,14 +94,19 @@ class RepositoriesController < ApplicationController HOOK_TEMPLATE = %Q{#!/bin/sh -exec git update-server-info - -CMD_PATH=`dirname $0` -cd $CMD_PATH -PY_PATH=$PWD/../../git_refresh_changes.py -[[ -s "$PY_PATH" ]] && $(which python) $PY_PATH $(dirname $PWD) -cd - +exec sh -c ' +function update() +{ + CMD_PATH=`dirname $0`; + cd $CMD_PATH; + PY_PATH=$PWD/../../git_refresh_changes.py; + [[ -s "$PY_PATH" ]] && $(which python) $PY_PATH $PWD; + cd -; } +git update-server-info +update +' + } def create if params[:repository_scm].to_s == 'Gitlab' diff --git a/lib/tasks/git_post_update.rake b/lib/tasks/git_post_update.rake index 170bd0467..18ed4fbc8 100644 --- a/lib/tasks/git_post_update.rake +++ b/lib/tasks/git_post_update.rake @@ -1,14 +1,18 @@ namespace :git_post_update do HOOK_TEMPLATE = %Q{#!/bin/sh - -exec git update-server-info - -CMD_PATH=`dirname $0` -cd $CMD_PATH -PY_PATH=$PWD/../../../git_refresh_changes.py - [[ -s "$PY_PATH" ]] && $(which python) $PY_PATH $(dirname $PWD) - cd - +exec sh -c ' +function update() +{ + CMD_PATH=`dirname $0`; + cd $CMD_PATH; + PY_PATH=$PWD/../../git_refresh_changes.py; + [[ -s "$PY_PATH" ]] && $(which python) $PY_PATH $PWD; + cd -; +} +git update-server-info +update +' } desc "update old post-update file, REP_PATH"