Open Bug 1772716 Opened 2 years ago Updated 2 years ago

`hg commit` automatically invokes `mach lint` or similar, and it's not clear how to disable this behaviour

Categories

(Developer Infrastructure :: Lint and Formatting, defect, P3)

Tracking

(Not tracked)

People

(Reporter: botond, Unassigned)

Details

On a recent mozilla-central checkout, I'm finding that hg commit automatically invokes mach lint (or something similar that auto-adds e.g. formatting changes to js files to the commit).

I would like to disable this, for a couple of reasons:

  • It increases the running time of hg commit by a fair bit.
  • In some cases, it introduces changes into a changeset that don't belong there (e.g. modifying other parts of the file) and mess up attempts to e.g. reorder patches with hg histedit due to conflicts.

However, it's not obvious to me how to disable this behaviour. Some searching around suggests that automatic actions upon commit are configured by adding a [hooks] section to .hg/hgrc, but there is no such section in my hgrc, nor does hg --debug showconfig show mercurial picking up a hook from anywhere else.

What is the mechanism by which this auto-linting is happening, and how can I disable it?

The only thing I know about on how to set this up is https://firefox-source-docs.mozilla.org/code-quality/lint/usage.html#using-a-vcs-hook

You would probably be better off asking in #vcs on matrix, or maybe #lint.

If modifications are happening to other parts of the file, then I would recommend asking/filing about those specifically. My guess is that it is clang-format, which unfortunately doesn't cause test failures on CI if developers haven't kept it up to date.

You should see an entry in the extensions section of your .hgrc called js-format and clang-format - these extensions add the lint-on-commit behaviour and you can disable them by commenting out the extension.

I agree the discoverability isn't great if you aren't aware of the extensions. Perhaps we could add a flag to disable the linting on a per-command basis.

(In reply to Connor Sheehan [:sheehan] from comment #2)

You should see an entry in the extensions section of your .hgrc called js-format and clang-format - these extensions add the lint-on-commit behaviour

Thanks, this was it.

I think part of the confusion is that I saw a line of output that read something like 0 problems (0 errors, 0 warnings, 1 fixed), and it looked like something more than just a formatter (though in retrospect that seems like a reasonable thing for a formatter to print).

The severity field is not set for this bug.
:andi, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(bpostelnicu)

Does this answer your question, can we close this?

Flags: needinfo?(bpostelnicu) → needinfo?(botond)

My question is answered, thanks.

Connor had an actionable suggestion in comment 2:

Perhaps we could add a flag to disable the linting on a per-command basis.

If we wanted to pursue that we could track that in this bug, otherwise it can be closed.

Flags: needinfo?(botond)
Product: Firefox Build System → Developer Infrastructure

The severity field is not set for this bug.
:andi, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(bpostelnicu)
Severity: -- → S3
Flags: needinfo?(bpostelnicu)
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.