bash脚本提取混帐名whatchanged [英] Bash script to extract filenames from git whatchanged

查看:176
本文介绍了bash脚本提取混帐名whatchanged的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让这变为知道什么reminify所有的JS文件的列表。

I'm trying to get a list of all the js files that changed to know what to reminify.

我previously问<一个href=\"http://stackoverflow.com/questions/9361496/save-a-modified-log-right-before-a-commit/9361595#comment11832771_9361595\">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?

推荐答案

从<一个href=\"http://stackoverflow.com/questions/424071/how-do-i-list-all-the-files-for-a-commit-in-git\">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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆