核心说明
- git diff --name-only new_commit_id old_commit_id 查看两个提交之间更新的文件
- xargs 是一个强有力的命令,它能够捕获一个命令的输出,然后传递给另外一个命令。
- zip 打包到压缩程序
#!/bin/bash
date=`date +%Y%m%d`
#git diff new-version old-version --name-only | xargs zip update.zip
#git diff --name-only 7087660ecc73bba974367209ff26819e9409f9b2 ca3b76effaee63d75473184fc3d49c204c71c939
if [ $# -ne 3 ];then
echo "Usage: command [module name] [new commit id] [old commit id]"
exit 1;
fi
MODULE_NAME=$1
COMMIT_NEW=$2
COMMIT_OLD=$3
cd ${MODULE_NAME}
FILENAME=update_${MODULE_NAME}_${COMMIT_NEW:0:7}_${COMMIT_OLD:0:7}_${date}.zip
# git diff --name-only ${COMMIT_NEW} ${COMMIT_OLD} | xargs zip update_${MODULE_NAME}_${COMMIT_NEW:0:7}_${COMMIT_OLD:0:7}_${date}.zip
git diff --name-only ${COMMIT_NEW} ${COMMIT_OLD} | xargs zip ${FILENAME}
mv ${FILENAME} ../