git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: problem with not being able to enforce git content filters

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Oct 17, 2018, 00:54 UTC
Message-ID
<20181017005424.GH432229@genre.crustytoothpaste.net>
In-Reply-To
<038d40b9-0b35-b93f-9377-7c0bb12bce8e@stason.org>
On Tue, Oct 16, 2018 at 04:48:13PM -0700, Stas Bekman wrote:
Show 16 quoted lines
> 
> >> And the devs honestly try to do their best to remember to configure the
> >> filters, but for some reason they disappear for them, don't ask me why,
> >> I don't know. This is an open source project team, not a work place.
> > 
> > This sounds like it could be easily solved by continuous integration.
> > You could set up a job on any of a variety of services that checks that
> > a pull request or other commit is clean when when the filter runs.  If
> > it doesn't pass, the code doesn't merge.
> 
> This is an excellent idea wrt to PRs. Thank you, Brian! I will implement
> that.
> 
> It doesn't help with direct commits to master, since CI would be
> detecting it after it was committed. And when that happens we all know
> that already because 'git pull' fails.

Typically projects that have CI set up don't allow direct pushes to master, since that tends to allow to bypass CI, or they allow it only in exceptional circumstances (e.g., reverts). Also, typically most projects want to have some sort of review before code (resp. documents, other contributions) are merged. Most Git hosting platforms, including GitHub, offer protected branches, so it's something to consider.

There is a possible alternative, and that's that if your project has some sort of build file (e.g., a Makefile), you can set it up to automatically insert hooks or git configuration into developers' systems, optionally only if it's in a Git repository. For example, you could add a pre-commit hook that fails if the filters are disabled.

These are the approaches that tend to work well for most projects. I tend to prefer the CI approach with restricted branches because often I want to customize my hooks, but your project will decide what works best for it.

-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204
Previous: Stas BekmanNext: Stas Bekman
Message 6 of 7 in “problem with not being able to enforce git content filters”
  1. Stas BekmanOct 16, 2018
  2. Ævar Arnfjörð BjarmasonOct 16, 2018
  3. Stas BekmanOct 16, 2018
  4. brian m. carlsonOct 16, 2018
  5. Stas BekmanOct 16, 2018
  6. brian m. carlsonOct 17, 2018
  7. Stas BekmanOct 17, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.