0

如何组合两个接收后挂钩?第一个是git-slack 集成,并使用以下循环运行:

while read line
do
  set -- $line
  notify $*
  RET=$?
done

第二个用于我的部署,如下所示:

while read oldrev newrev refname line
do
   branch=$(git rev-parse --symbolic --abbrev-ref $refname)
   if [ "master" = "$branch" ]; then
     # some deployment commands
   elif [ "development" = "$branch" ]; then
     # some other deployment commands
   fi
done

无论我为 git 使用什么分支,我都希望能够向 slack 发送通知。

关于如何组合两个循环的任何提示?

4

1 回答 1

2

这尚未经过测试,但应该可以工作:

while read oldrev newrev refname line
do
  set -- "$oldrev $newrev $refname $line"
  notify $*

  # Not sure the return value is needed since it isn't being used anywhere
  RET=$?

  branch=$(git rev-parse --symbolic --abbrev-ref $refname)
  if [ "master" = "$branch" ]; then
    # some deployment commands
  elif [ "development" = "$branch" ]; then
   # some other deployment commands
  fi
done

希望这可以帮助

于 2015-12-01T19:50:51.047 回答