Closed
Bug 1507007
Opened 6 years ago
Closed 5 years ago
Provide a script for local precommit hg/git hooks that run ./mach clang-format
Categories
(Developer Infrastructure :: Lint and Formatting, enhancement)
Developer Infrastructure
Lint and Formatting
Tracking
(firefox66 fixed)
RESOLVED
FIXED
Tracking | Status | |
---|---|---|
firefox66 | --- | fixed |
People
(Reporter: ehsan.akhgari, Assigned: Sylvestre)
References
()
Details
Attachments
(1 file, 1 obsolete file)
We can use https://searchfox.org/mozilla-central/source/tools/lint/hooks.py as a guide.
Assignee | ||
Comment 1•6 years ago
|
||
I think I have something for that. With my patch, I am producing the following output: % hg commit --amend dom/ tools/ Running command: ['/usr/bin/python2.7', '/home/sylvestre/dev/mozilla/mozilla-central.hg/tools/lint/../../mach', 'clang-format', '-s'] --- dom/presentation/PresentationReceiver.cpp (before formatting) +++ dom/presentation/PresentationReceiver.cpp (after formatting) @@ -67,8 +67,7 @@ return !mUrl.IsEmpty(); } -void PresentationReceiver::Shutdown( ) -{ +void PresentationReceiver::Shutdown() { PRES_DEBUG("receiver shutdown:windowId[%" PRId64 "]\n", mWindowId); // Unregister listener for incoming sessions. Running command: ['/usr/bin/python2.7', '/home/sylvestre/dev/mozilla/mozilla-central.hg/tools/lint/../../mach', 'lint', '--quiet', '--workdir=staged'] ✖ 0 problems (0 errors, 0 warnings)
Assignee | ||
Updated•6 years ago
|
Assignee: nobody → sledru
Assignee | ||
Comment 2•6 years ago
|
||
As ride along, other changes: 1) Renamed run_mozlint =>run_linters 2) Show the command being executed (we have the mozlint output anyway) 3) Add a link to the doc on how to use it
Assignee | ||
Comment 4•6 years ago
|
||
Andrew is the real expert here :)
Flags: needinfo?(sledru) → needinfo?(ahal)
Comment 5•6 years ago
|
||
I had to Google it, but looks like you can do stuff like: [hooks] pre-qrefresh.lint = hook.py So I guess yes :). Though I'm also not sure how mq interacts with |mach lint|'s --workdir and --outgoing flags respectively (which is what the hooks call into). So further testing is needed to properly answer that.
Flags: needinfo?(ahal)
Comment 6•6 years ago
|
||
Also the hooks.py file looks for either "commit" or "push" in the hook name. So we'd have to teach it about 'qrefresh' (or whatever other mq commands we need).
Assignee | ||
Comment 7•6 years ago
|
||
Comment 8•6 years ago
|
||
Please make sure that this hook will not prevent win32 native python from landing commits. (See bug 1511594 for context.)
Updated•5 years ago
|
Attachment #9027313 -
Attachment is obsolete: true
Pushed by sledru@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e2b466629175 Add a clang-format hook r=ahal,Ehsan
Comment 10•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/e2b466629175
Assignee | ||
Comment 11•5 years ago
|
||
Here is how this can be configured: ---- [hooks] pretxncommit.clang-format = python:./tools/lint/hooks_clang_format.py:hg ---- in .hg/hgrc
Comment 12•5 years ago
|
||
This doesn't work in git: Traceback (most recent call last): File ".git/hooks/pre-commit", line 48, in <module> sys.exit(git()) File ".git/hooks/pre-commit", line 44, in git return run_clang_format(hooktype, []) TypeError: run_clang_format() takes exactly 3 arguments (2 given) Also hooks_clang_format.py should be marked executable for best results.
Flags: needinfo?(sledru)
Assignee | ||
Comment 13•5 years ago
|
||
I didn't test this on git, let me fix that.
Flags: needinfo?(sledru)
Assignee | ||
Updated•5 years ago
|
Updated•2 years ago
|
Product: Firefox Build System → Developer Infrastructure
You need to log in
before you can comment on or make changes to this bug.
Description
•