betterer icon indicating copy to clipboard operation
betterer copied to clipboard

Error: .git directory not found. Betterer must be used within a git repository.

Open davidbarratt opened this issue 1 year ago • 7 comments

Describe the bug Betterer requires a .git directory

To Reproduce Run betterer ci without a .git directory.

Expected behavior I expected betterer to create a new results file and use diff (or something like it) in order to check for differences.

Screenshots N/A

Versions (please complete the following information):

  • OS: Linux
  • Betterer Version: 5.4.0
  • Node Version: 16.x

Additional context I don't really understand why it would need git in the CI

davidbarratt avatar Mar 13 '23 14:03 davidbarratt

This is by design, as git is useful for more than just diff checking, (e.g. for maintaining the cache), and most CI systems are have got available for cloning the project they are building. Not planning on changing this, but happy to look at a PR.

phenomnomnominal avatar Mar 13 '23 23:03 phenomnomnominal

I hope you might reconsider, if you are using a multi-stage Dockerfile for testing, requiring git to work properly means the entire layer is uncachable since you have to copy the ./.git directory which changes on each commit regardless if any files have actually changed.

davidbarratt avatar Mar 15 '23 13:03 davidbarratt

Fair enough, I'll have a think

phenomnomnominal avatar Mar 18 '23 03:03 phenomnomnominal

I agree with @davidbarratt that multi-stage Dockerfile's are very common in CI. Requiring .git essentially rules out this tool for anyone using that workflow.

I haven't looked at this library close enough yet to understand how difficult it will be to remove the requirement but if you have any ideas I am happy to try and help contribute to a fix.

mtimbs avatar Mar 21 '23 12:03 mtimbs

This is an issue for us as well, our CI uses docker and doesn't copy over the .git folder.

martsie avatar Aug 22 '23 06:08 martsie

Just ran into this issue as well, and git is just used to list files, so git init && git add . && git commit -m dummy works as a workaround, but it's ugly, and the dependency on git should just be removed or have a flag to toggle off.

slikts avatar Jun 26 '24 09:06 slikts