shibapm / Komondor

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

Discussion: how to use in collaborative environments #43

Open mamouneyya opened 3 years ago

mamouneyya commented 3 years ago

Interested to hear any thought from the community on how to leverage this in a large team. We have so many separate packages that we would like to automate the process of linting / formatting for each one and without people doing any extra step(s) to setup or execute anything.

I know a server based solution might work better for this use case, but I'm still very interested in exploring any possibility to implement this on the client side, for the very reasons the author of this package listed (e.g. detecting errors as early as possible, having linting and formatting amended to each commit so we have cleaner history, etc.).

I can think of 2 problems right now:

  1. Since Git ignores hooks by default, what would be the best way to share this setup and have it installed on everyone's machine without the need for them to run the install command or anything? (I'm trying to make this 100% transparent to avoid current process's pain which require the engineers to execute a couple of commands where they, especially juniors, can pretty easily forget or get them wrong)
  2. I believe this is easier but I am not very familiar with SPM's executables to confirm. Let's say we could find a solution for (1), and given we have so many packages, what would be an easy way to avoid this boilerplate in each Package.swift manifest file? Can we probably package it as a wrapper executable dependency that can be just added to every package? The goal is to be able to reuse it across different packages with minimal effort and having a centralized single configurations.

Thanks a lot!

orta commented 3 years ago

1, SPM doesn't allow for arbitrary code evaluation so you can't really check if someone has set up the git hook. Perhaps if you use CocoaPods you can use the Podfile to validate that someone has githooks set up

2, Perhaps you could have a shared library, or scripts which are cloned during the repo strapping and are referenced from your Komondor scripts

mamouneyya commented 3 years ago

1, SPM doesn't allow for arbitrary code evaluation so you can't really check if someone has set up the git hook. Perhaps if you use CocoaPods you can use the Podfile to validate that someone has githooks set up

Let's say we want to re-install them always regardless, how would you execute this automatically and where?

orta commented 3 years ago

In a repo bootstrap shell script maybe?

minuscorp commented 2 years ago

https://medium.com/@KaneCheshire/swift-package-manager-is-a-security-risk-4d13f3a7bc3b