0

I am trying to obtain a list of files that were merged during a merge request. The point is, we need to know for sure, which branch these files belong to. Dev branch or feature/DHO-XXX_YYYYYYY branch. We only care for files that belongs to feature/DHO-XXX_YYYYYYY.

What I tried was the following command: (However is not optimal, because we do not know which file belong to which branch)

git log --diff-filter=AM --pretty=format:"%s" -m --name-only --grep="feature/DHO" --since=1.week


Merge branch 'feature/DHO-BBB_samtest' into feature/sam_dev_test
test DHO-BBB.txt

Merge branch 'feature/DHO-BBB_samtest' into feature/sam_dev_test
FileForTestingMergeWithDev.txt

Merge branch 'feature/DHO-AAA_samTest' into feature/sam_dev_test
test DHO-AAA.txt

Merge branch 'feature/DHO-AAA_samTest' into feature/sam_dev_test
FileForTestingMergeWithDev.txt

Would someone know how could I do it?

Samuel D
  • 75
  • 1
  • 3
  • 10
  • 2
    What do you mean exactly by "which branch these files belong to"? Files are not linked to specific branches, and anyway, a branch is a just very light-weight pointer to one given commit. However, you *could* check if file X or Y is reachable from that branch. – Romain Valeri Oct 12 '18 at 14:32
  • lets say you have files A.txt and B.txt in branch feature/DHO-XXX and in your branch development you had already file C.txt and D.txt. We are in branch dev and we merge branch feature/DHO-XXX in it. How can we show that files A.txt and B.txt were originally in feature/DHO-XXX ? – Samuel D Oct 12 '18 at 14:40
  • 2
    When a file is reachable *only* from one branch but not the other, fine. But what is the result you're expecting for cases where the file exists on both sides? – Romain Valeri Oct 12 '18 at 14:46
  • 1
    Not to wander into XY problem teritory but.... can you give a hint at why you guys try to get this information? *Maybe* there's a better way to achieve the end goal? Ow, this might be more than just wandering into XY problem teritory. FSM help us. – Romain Valeri Oct 12 '18 at 14:51
  • it is no problem that the file also exists in the other branch. We want to list files that are present in feature/DHO-XXX. We need this because: 1) we use JIRA to track code requests promotion to production 2) during the release process, we perform integration test, we put all file in same "bucket", so we lose track of which file belong to which JIRA number. 3) By retracing the feature/DHO-XXX , and link it with each file, we will have this traceability again. Does it make sense ? – Samuel D Oct 12 '18 at 15:10
  • Could it be handled with enforcing the good habit of putting the JIRA code into commit messages? We do this here and it's working fine. It also reminds me of [this question](https://stackoverflow.com/questions/52755018/identifying-commits-that-were-done-on-a-branch) earlier today. – Romain Valeri Oct 12 '18 at 15:17
  • actually the branch name is the JIRA prefix already , so when there is a merge we already have this detail in the message: "Merge branch 'feature/DHO-BBB_samtest' into feature/sam_dev_test FileForTestingMergeWithDev.txt" - in this case DHO-BBB. Still , by the command I have pasted above, I cannot distinguish which files belong to the branch feature/DHO-BBB_samtest and which ones were from dev (feature/sam_dev_test) – Samuel D Oct 12 '18 at 15:21
  • So just look at the commits you're interested in, `git log merge^2 --diff-filter=` etcetera. – jthill Oct 12 '18 at 20:00

0 Answers0