Travis configuration of phpcs for only current commit files

╄→尐↘猪︶ㄣ 提交于 2019-12-06 15:47:42

What you could try is the following:

get last commit id: (How to get the last commit ID of a remote repo using curl-like command?)

git log --format="%H" -n 1

Then get files in last commit: (How to list all the files in a commit?)

git diff-tree --no-commit-id --name-only -r `git log --format="%H" -n 1`

You can see that previous command is used here. The first part before backtits needs a commit id to list files from. This commit id is found with the first command.

And then if you want only php files you can use grep :

git diff-tree --no-commit-id --name-only -r `git log --format="%H" -n 1` | grep .php

Output on one of my php project:

app/Http/Controllers/BarterController.php
app/Http/Controllers/HomeController.php
app/Talk.php
resources/views/profiles/index.blade.php
resources/views/talks/show-comments.blade.php

Simply replace your command $(find ./ -name '*.php') with the one I gave above and it should work. Your command would become the following:

phpcs --standard=PSR2 $(git diff-tree --no-commit-id --name-only -r `git log --format="%H" -n 1` | grep .php)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!