问题描述
我试图让这变为知道什么reminify所有的JS文件的列表。
I'm trying to get a list of all the js files that changed to know what to reminify.
我previously问this问题
I previously asked this question
到目前为止,这是我想出了最好的,但它感觉真的不安全。
So far this is the best I came up with but it feels really unsafe.
GITCHANGES=$(git whatchanged -n 1 --pretty=format:)
I=0;
for f in $GITCHANGES;
do
I=$(($I + 1));
if [[ $(($I % 6 )) == 0 ]]; then
echo "$f"
fi
done
但是,这给了我一切都改变了( PHP
CSS
JS ),而不仅仅是
JS
文件
But this gives me all the files that changed (
php
css
js
) and not just the js
files
我怎么会得到只是js文件?也有没有更好的方式来做到这一点?
How would I get just the js files? Also is there a better way to accomplish this?
推荐答案
从this回答,使用
git的展示 - pretty =格式:--name-HEAD只^
来得到修改的文件的列表。然后把它管道的grep
。
From this answer, use
git show --pretty="format:" --name-only HEAD^
to get a list of changed files. Then pipe it through grep
.
git show --pretty="format:" --name-only HEAD^ | grep '\.js$'
这篇关于bash脚本提取混帐名whatchanged的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!