File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212 branches : [ main ]
1313
1414jobs :
15+ lint-pr-title :
16+ if : github.event_name == 'pull_request'
17+ runs-on : ubuntu-latest
18+ steps :
19+ - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
20+ - name : Set up Python
21+ uses : actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
22+ with :
23+ python-version : " 3.12"
24+ - name : Lint PR title
25+ run : python ops/lintcommit.py --subject "${{ github.event.pull_request.title }}"
26+
1527 build :
1628 runs-on : ubuntu-latest
1729 strategy :
Original file line number Diff line number Diff line change @@ -192,7 +192,28 @@ def run_local() -> None:
192192
193193
194194def main () -> None :
195- run_local ()
195+ import argparse
196+
197+ parser = argparse .ArgumentParser (
198+ description = "Lint commit messages for conventional commits compliance."
199+ )
200+ parser .add_argument (
201+ "--subject" ,
202+ default = None ,
203+ help = "Validate a single subject line (e.g. a PR title). "
204+ "When omitted, runs in local mode checking commits ahead of origin/main." ,
205+ )
206+ args = parser .parse_args ()
207+
208+ if args .subject is not None :
209+ error : str | None = validate_subject (args .subject )
210+ if error :
211+ print (f"FAIL: { args .subject } " , file = sys .stderr )
212+ print (f" Error: { error } " , file = sys .stderr )
213+ sys .exit (1 )
214+ print (f"PASS: { args .subject } " )
215+ else :
216+ run_local ()
196217
197218
198219if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments