如何在Git post-receive hook中获取已更改文件的列表?

时间:2015-11-02 19:06:33

标签: git git-post-receive

我需要在服务器端钩子中获取已更改文件的列表。例如:

Local commit 1:

M test.txt
M test2.txt

Local commit 2:

M test.txt
A test3.txt

两个提交都被推送到服务器(裸仓库)。我需要遍历文件列表并通过curl在其他地方发布每个文件:

M test.txt
M test2.txt
A test3.txt

我努力寻找文档来实现这一目标。我知道这些修改是向stdin吐出来的。我如何实际循环推送文件,并引用它们进行卷曲上传(这看起来很难,因为它是一个简单的回购)?

#!/bin/bash

while read oldrev newrev refname; do
  echo $oldrev
  echo $newrev
  echo $refname
done < "${1:-/dev/stdin}"

0 个答案:

没有答案
相关问题