0

I'm trying to get a consolidated list of changes (file paths and new/modified/deleted changes) from a commit/pull request in Github.

This is the format I'm trying to aim for:

filepath/to/some/file.properties:thisIsAKey=This is the string for this key.

I'm able to grab filepaths relatively easily using:

git show --pretty="format:" --name-only commitID

I also tried this but it includes a lot of noise:

git log -p commitID

Here's what I have from using the above, but I only need the b/+ changes:

diff --git a/locales/ES/es/forms/dispute-options.properties b/locales/ES/es/forms/dispute-options.properties
index 490457e9e0..569921196a 100644
--- a/locales/ES/es/forms/dispute-options.properties
+++ b/locales/ES/es/forms/dispute-options.properties
@@ -60,4 +60,5 @@ fraudSeller.info=Para cancelar este pedido tendrá que comunicarse directamente
 fraudSeller.errorHeadingMessage = Lo sentimos, pero no puede reportar este tipo de problema para la transacción seleccionada.
 fraudSeller.backButtonText = Atrás

-modal.cancel=Cancel
\ No newline at end of file
+modal.cancel=Cancel
+disputeOptions.creditTransactionInfo=Si presenta un caso para esta compra, aún tendrá que continuar pagando cualquier saldo importe dejado en su plan de {data.pageStore.value.creditProductDescriptor} junto con la comisiones tardía (si corresponde).

I've been reading the documentation on how to use diff-filter, but haven't seen anything that matches what I need yet.

Edit: Thanks for everyone's comments! It led me to the answer I was looking for: git diff -U0 --ignore-all-space commitID1 commitID2 | grep '^[+]' | grep -Ev '^(--- a/)' > test.txt

1 Answers1

1

Given that you are talking about PRs (which can mean many revisions, not just one), I think you have to try:

git diff --name-only base-branch...pr-branch

notice the triple dot

That should give you the list of added/deleted/modified files.

eftshift0
  • 26,375
  • 3
  • 36
  • 60
  • What is `...` vs `..`? I use `..` all the time. Is that inclusive? – EncryptedWatermelon Mar 06 '20 at 16:58
  • 1
    `..` means the difference between the two branches. So... you want to check the changes introduced by a PR. That's good. If the branch where you started from **hasn't** moved, then you will get the changes from the PR using `..`... but what about if the base branch **has** moved? Then you get the changes from the PR... PLUS the changes introduced on the base branch since the 2 branches diverged. If what you want is the changes introduced the by the PR _only_ then you have to use the tripple dot. Then git will check where the branches diverged and then diff from there. – eftshift0 Mar 06 '20 at 17:02
  • Interesting. I've used `git merge-base` to accomplish that in the past. – EncryptedWatermelon Mar 06 '20 at 17:06
  • And then diff from there? Sure that works.... only that `...` does that for you instead. – eftshift0 Mar 06 '20 at 17:07
  • Yep, diff from there. Just didn't know the `...` syntax. Thanks – EncryptedWatermelon Mar 06 '20 at 17:10
  • 2
    @EncryptedWatermelon https://stackoverflow.com/a/7256391/7976758 – phd Mar 06 '20 at 17:59
  • @eftshift0 Thanks! Will this also give me the changes in the commit/PR as well? I haven’t tried it yet, but thought I would ask first. Thanks again. – Duong Nguyen Mar 07 '20 at 17:28
  • Without `--name-only`? Sure! – eftshift0 Mar 08 '20 at 02:12