Closed
Bug 1590328
Opened 5 years ago
Closed 5 years ago
Pre-commit linting hook not working with git
Categories
(Developer Infrastructure :: Lint and Formatting, defect)
Developer Infrastructure
Lint and Formatting
Tracking
(firefox72 fixed)
RESOLVED
FIXED
mozilla72
Tracking | Status | |
---|---|---|
firefox72 | --- | fixed |
People
(Reporter: wingo, Assigned: Mardak)
References
(Regression)
Details
(Keywords: regression)
Attachments
(1 file)
I linked .git/hooks/pre-commit to tools/lint/hooks_clang_format.py, as suggested in the cinnabar readme. However this stopped working after bug 1586010 landed earlier this month:
wingo@milano:~/src/mozilla-unified$ ./mach try fuzzy -q linux64
Traceback (most recent call last):
File ".git/hooks/pre-commit", line 17, in <module>
from mozversioncontrol import get_repository_object, InvalidRepoPath
File "/home/wingo/src/mozilla-unified/tools/lint/../../python/mozversioncontrol/mozversioncontrol/__init__.py", line 14, in <module>
from mozbuild.util import ensure_subprocess_env
ImportError: No module named mozbuild.util
Error running mach:
['try', 'fuzzy', '-q', 'linux64']
The error occurred in code that was called by the mach command. This is either
a bug in the called code itself or in the way that mach is calling it.
You can invoke |./mach busted| to check if this issue is already on file. If it
isn't, please use |./mach busted file| to report it. If |./mach busted| is
misbehaving, you can also inspect the dependencies of bug 1543241.
If filing a bug, please include the full output of mach, including this error
message.
The details of the failure are as follows:
CalledProcessError: Command '(u'/home/wingo/.guix-profile/bin/git', u'-c', u'commit.gpgSign=false', u'commit', u'--allow-empty', u'-m', u'Fuzzy query=linux64\n\nPushed via `mach try fuzzy`')' returned non-zero exit status 1
File "/home/wingo/src/mozilla-unified/tools/tryselect/mach_commands.py", line 310, in try_fuzzy
return self.run(**kwargs)
File "/home/wingo/src/mozilla-unified/tools/tryselect/mach_commands.py", line 182, in run
return mod.run(**kwargs)
File "/home/wingo/src/mozilla-unified/tools/tryselect/selectors/fuzzy.py", line 449, in run
push=push, closed_tree=closed_tree)
File "/home/wingo/src/mozilla-unified/tools/tryselect/push.py", line 134, in push_to_try
vcs.push_to_try(commit_message)
File "/home/wingo/src/mozilla-unified/python/mozversioncontrol/mozversioncontrol/__init__.py", line 481, in push_to_try
self._run('-c', 'commit.gpgSign=false', 'commit', '--allow-empty', '-m', message)
File "/home/wingo/src/mozilla-unified/python/mozversioncontrol/mozversioncontrol/__init__.py", line 105, in _run
universal_newlines=True)
File "/usr/lib/python2.7/subprocess.py", line 223, in check_output
raise CalledProcessError(retcode, cmd, output=output)
The reason is that python/mozversioncontrol
now imports python/mozbuild
. A patch like this does the trick:
diff --git a/tools/lint/hooks_clang_format.py b/tools/lint/hooks_clang_format.py
index 663e6d4e4f10..c8253382b938 100755
--- a/tools/lint/hooks_clang_format.py
+++ b/tools/lint/hooks_clang_format.py
@@ -11,7 +11,7 @@ import sys
here = os.path.dirname(os.path.realpath(__file__))
topsrcdir = os.path.join(here, os.pardir, os.pardir)
-EXTRA_PATHS = ("python/mozversioncontrol",)
+EXTRA_PATHS = ("python/mozversioncontrol", "python/mozbuild",)
sys.path[:0] = [os.path.join(topsrcdir, p) for p in EXTRA_PATHS]
from mozversioncontrol import get_repository_object, InvalidRepoPath
Reporter | ||
Comment 1•5 years ago
|
||
FWIW I tested this locally by copying tools/lint/hooks_clang_format.py
to .git/hooks/pre-commit
instead of linking it, and editing locally.
Assignee | ||
Comment 3•5 years ago
|
||
Updated•5 years ago
|
Attachment #9107345 -
Attachment description: Bug 1590328 - Include mozbuild path now that mozversioncontrol uses it r=ahal! → Bug 1590328 - [mozlint] Include mozbuild path now that mozversioncontrol uses it r=ahal!
Pushed by elee@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/9c6862eee5b2 [mozlint] Include mozbuild path now that mozversioncontrol uses it r=ahal
Comment 5•5 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 5 years ago
status-firefox72:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla72
Updated•5 years ago
|
Assignee: nobody → edilee
Updated•2 years ago
|
Has Regression Range: --- → yes
Updated•2 years ago
|
Keywords: regression
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
•