Teach ad-hoc hooks line-parsing using regexes in YAML

Offen
#750 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
15/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
ruby, yaml
Bereich
tooling

Rechercherichtung

The proposal centres on extract_messages and the MESSAGE_REGEX and MESSAGE_TYPE_CATEGORIZER constants that built-in hooks use to parse tool output, and asks whether ad-hoc hooks could declare the same behaviour in the YAML config. Read how built-in hooks use those constants and how ad-hoc hooks are loaded from the config, then settle the design questions in the thread. The issue is open-ended, so 'done' needs a maintainer decision on the config schema and testing approach first.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

enhancement

Many non-ad-hoc (pre-commit) hooks seem just to get the error code and parse stdout using extract_messages with the right MESSAGE_REGEX and MESSAGE_TYPE_CATEGORIZER.

Ad-hoc hooks could be taught how to do that from the overcommit YAML config file using:

  • one regex for the message (a good default being the Emacs format)
  • one optional regex to test whether the message is a warning or an error ("warning:" seems pretty common)
  • maybe one optional regex to prefilter lines (empty lines, non-standard line, etc.), and flags to capture stdout and/or stderr, if we really need or want to handle more cases

Of course I guess in the end it all boils down to whether one prefers Ruby to regexes! 😉
Anyway this might still be a good alternative for non-Ruby programmers to easily contribute hooks, and a good way to write less code (although I am not sure yet how tests could be written).

Thoughts?

Vorherrschende Sprache
Ruby
Sterne
4k
Forks
288
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
18

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus sds/overcommit

Alle Issues in sds/overcommit

Ähnliche Issues

Weitere Issues zu Ruby

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.