shibapm / Komondor

Git Hooks for Swift projects 🐩
MIT License
552 stars 32 forks source link

Support for a separate configuration file #49

Open ivanlisovyi opened 2 years ago

ivanlisovyi commented 2 years ago

Context

This PR adds support for a separate config file that could be used instead of Package.swift to configure the komondor git hooks. The separate config file is a viable choice when you wanna komondor with something like Mint or other similar tools.

By default, komondor is going to use Package.swift to configure hooks and when --use-config-file flag is being used komondor gonna try to use komondor.yml file from the project root folder.

--use-config-file flag is supported by install and run commands.

Examples

With install command

swift run -c release komondor install --use-config-file

With run command

swift run -c release komondor run pre-commit --use-config-file

Additional Notes

  1. This closes #19
  2. This PR doesn't contain any unit tests because with the current package setup it's really hard to have any. I think to support the unit tests properly the majority of komondor source code needs to be moved to a separate target. I think this kind of change is a little bit out of the scope of this PR. It shall be relatively straightforward to extract the source code into a separate target (e.g. KomondorCore or KomondorFramework) and shall be probably done in a separate PR (I will be glad to do that in a follow-up PR).
orta commented 2 years ago

Oops, I missed this - sorry.

I'm open to the idea, but I'd rather not gain another dependency to pay for it - if the config was JSON 👍🏻. WRT adding tests, I'm open to those changes too 👍🏻