在Git/GitHub中列出在拉取请求中更改的所有文件
是否有一种方法(从命令行)列出Git/GitHub中PR中所有已更改文件的名称?这将用于查找需要在该PR的Travis CI构建中运行哪些测试.
Is there a way (from the command line) to list the names of all files changed in a PR in Git/GitHub? This would be used to find what tests need to be run in a Travis CI build for that PR.
CI构建在调用脚本之前运行以下命令:
The CI build runs these commands before it calls our script:
git clone --depth=50 git://github.com/jekyll/jekyll.git jekyll/jekyll
cd jekyll/jekyll
git fetch origin +refs/pull/2615/merge
git checkout -qf FETCH_HEAD
通常,您可以使用git diff --name-only
列出在两次提交之间更改的文件:
In general, you can list the files changed between any two commits with git diff --name-only
:
这里的问题似乎是确定合并基础".如果所有分支都源自master,那么您可以:
The problem here seems to be determining the 'merge base'. If all branches originate with master, then you could do:
git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD master)
这将向您显示FETCH_HEAD
从master
分支到当前FETCH_HEAD
的点之间的变化.我在本地进行了测试,并且PR分支是从master
剪切而来的,我相信它应该可以工作.
This will show you the changes between the point at which the FETCH_HEAD
was branched from master
to the current FETCH_HEAD
. I tested this locally, and the PR branches are cut from master
I believe it should work.