我有一个钩子,可以获取更改的文件并将它们复制到它适用于标准提交的目录,但是合并的自动提交会破坏它,因为最后两个提交不包含任何更改的文件
这是我当前的代码
generateChangeSet() {
if [ ! -d $WORKDIR ];then
mkdir $WORKDIR
fi
CHANGESET=$(git log -1 --name-status $oldrev $newrev | grep -v -e "^Merge" -e "^commit" -e "^Author" -e "^Date" -e "^ " -e "^$")
if [ -z $CHANGESET ]; then
echo Could not detect any files in the change set, aborting push
exit $RETVAL
fi
# Get a list of deleted files
DELFILES=$WORKDIR/deletedFiles.sh
if [ -f $DELFILES ];then
rm -rf $DELFILES
fi
for dFile in $(echo $CHANGESET | grep "^D" | awk '{print $2}'); do
echo deleted file $dFile
echo rm -f $dFile >> $DELFILES
done
if [ -f $DELFILES ];then
sed -i '1s/^/#!\/bin\/bash\n/' $DELFILES
chmod +x $DELFILES
echo find . -depth -type d -empty >> $DELFILES
echo rm deletedFiles.sh >> $DELFILES
fi
echo "Generating diff between $newrev and $oldrev"
git archive HEAD $(echo $CHANGESET | grep -v "^D" | awk '{print $2}') | (cd $WORKDIR && tar xf -)
}
关于如何让脚本始终获取最新更改文件的任何想法?
谢谢