在Git/GitHub中列出在拉取请求中更改的所有文件 [英] List all files changed in a pull request in Git/GitHub

查看:199
本文介绍了在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_HEADmaster分支到当前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.

这篇关于在Git/GitHub中列出在拉取请求中更改的所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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