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

未關閉
#750 5 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
15/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
ruby, yaml
領域
tooling

研究方向

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.

由索引模型根據 Issue 內容生成。

描述

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?

主要語言
Ruby
星號
4k
分支
288
平均合併
2 天 4 小時
30 天內合併 PR
18

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

sds/overcommit 的其他 Issue

查看 sds/overcommit 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。