-1

I'd like to write a test that

  1. fetches which file names exist in a specific package of a remote git branch and then
  2. checks if files with that name exist in a specific package of another remote git branch.

The test should run automatically via continuous integration.

As my project uses GitLab, solutions that use their API or similar would be feasible.

I've searched for answers and the only result I could find was this thread. However, I don't know how it could be possible to do this within an automatic test.

How could I achieve this?

  • What’s a package in this context? – evolutionxbox Jun 15 '20 at 08:17
  • The linked answer doesn't work on a remote repository. It works on a **local** remote-tracking branch. This is probably the only way to go — fetch commits locally and list files in them. – phd Jun 15 '20 at 10:20

1 Answers1

1

If this is acceptable : the easiest way is to fetch from the two remotes, and then run your tests locally.

One way to get the content of a "directory stored in a commit" is ls-tree -r (add --name-only if you only want the filenames) :

git ls-tree --name-only -r upstream/branchname -- path/to/dir
#                           ^                      ^
#          anything that identifies a commit      path to check inside that commit
LeGEC
  • 46,477
  • 5
  • 57
  • 104