Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gitlint: do not allow treewide as an area in commit messages #71091

Merged
merged 1 commit into from
Apr 10, 2024

Conversation

nashif
Copy link
Member

@nashif nashif commented Apr 4, 2024

Treewide changes touching a single area or topic should have the
area/subsystem at the start of the commit message. Treewide is very
ambigous.

Signed-off-by: Anas Nashif anas.nashif@intel.com

@nashif nashif added Trivial Changes that can be reviewed by anyone, i.e. doc changes, minor build system tweaks, etc. and removed area: Documentation area: Coding Guidelines Coding guidelines and style area: Continuous Integration labels Apr 4, 2024
@nashif nashif force-pushed the topic/gitlint/treewide branch from f094867 to f355ae8 Compare April 4, 2024 13:17
Copy link
Collaborator

@kartben kartben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure this is needed, using "treewide:" is no different from having a typo in the name of the subsystem/area or making up a new keyword that will never get used again, and we don't have checks for neither of this situations. I think having "good" prefixes eventually boils down to reviewers (and maintainer in particular) paying attention to the commit title and confirming it's to their liking for their area?

@nashif
Copy link
Member Author

nashif commented Apr 4, 2024

not sure this is needed, using "treewide:"

this is becoming a pattern in many PRs and you have to look closely to spot this. We do not have a preset list of allowed prefixes and I do not think we should have, detecting this and preventing "treewide" in the compliance check is still useful.

ec5df8a0e5f treewide: fix board identifier in overlays for lpcxpresso55s69 [Daniel DeGrasse/Anas Nashif]
8b456ea2a12 treewide: Replace all uses of CONCAT with _CONCAT [Alberto Escolar Piedras/Carles Cufí]
564adad952f treewide: Add CODE_UNREACHABLE after k_thread_abort(current) [Flavio Ceolin/Carles Cufí]
5c88d455448 treewide: mgmt: mcumgr: Change "ret" to "err" for SMP version 2 [Jamie McCrae/Carles Cufí]
a30862455e7 treewide: rename Microsemi to Microchip [Filip Kokosinski/Carles Cufí]
6b532ff43ec treewide: Update clock control API usage [Pieter De Gendt/Carles Cufí]
ec7044437e9 treewide: Disable automatic argparse argument shortening [Jamie McCrae/Stephanos Ioannidis]
47271ce8bee treewide: update usage of zephyr_code_relocate [Daniel DeGrasse/Carles Cufí]
cf211aa7aff treewide: Update deprecated CONFIG_LIB_CPLUSPLUS usages [Stephanos Ioannidis/Christopher Friedt]
a3b28ff0eb6 treewide: Use CONFIG_CPP_RTTI instead of CONFIG_RTTI [Stephanos Ioannidis/Christopher Friedt]
404e7a9bf73 treewide: Use CONFIG_CPP_EXCEPTIONS instead of CONFIG_EXCEPTIONS [Stephanos Ioannidis/Christopher Friedt]
4a64bfe3518 treewide: Use CONFIG_CPP instead of CONFIG_CPLUSPLUS [Stephanos Ioannidis/Christopher Friedt]
8e4d499fa07 treewide: Use CONFIG_*_ENDIAN instead of __BYTE_ORDER__ [Carles Cufi/Stephanos Ioannidis]
75680f7ae09 treewide: update flash_area name retrieval [Jordan Yates/Carles Cufí]
39782901e70 treewide: fix overlays after TF-M NS rename [Martí Bolívar/Christopher Friedt]
5be0d00d415 treewide: remove unnecessary DT GPIO/PWM flags checks [Martí Bolívar/Kumar Gala]
344c109f02a treewide: use full path to wifi/winc1500.h header [Peter Bigot/Carles Cufí]
9689868f7bd treewide: use full path to watchdog.h header [Peter Bigot/Carles Cufí]
84497d0e498 treewide: use full path to usb/usb_dc.h header [Peter Bigot/Carles Cufí]
02ae3431004 treewide: use full path to uart.h header [Peter Bigot/Carles Cufí]
5ceb612738a treewide: use full path to spi.h header [Peter Bigot/Carles Cufí]
165fe48229a treewide: use full path to sensor.h header [Peter Bigot/Carles Cufí]
12e30f16c96 treewide: use full path to pwm.h header [Peter Bigot/Carles Cufí]
e423639c41b treewide: use full path to ps2.h header [Peter Bigot/Carles Cufí]
4549d379dae treewide: use full path to pinmux.h header [Peter Bigot/Carles Cufí]
5e2b24a5e4b treewide: use full path to led/ht16k33.h header [Peter Bigot/Carles Cufí]
b3148570993 treewide: use full path to kscan.h header [Peter Bigot/Carles Cufí]
5e486b98b1b treewide: use full path to ipm.h header [Peter Bigot/Carles Cufí]
e0aa1b1e1dd treewide: use full path to ieee802154/cc2520.h header [Peter Bigot/Carles Cufí]
faa4bf34bda treewide: use full path to ieee802154/cc1200.h header [Peter Bigot/Carles Cufí]
8e2c230cbc9 treewide: use full path to i2c.h header [Peter Bigot/Carles Cufí]
81ca8888db9 treewide: use full path to hwinfo.h header [Peter Bigot/Carles Cufí]
5e470ec3bf6 treewide: use full path to gpio/gpio_mmio32.h header [Peter Bigot/Carles Cufí]
22bc403c178 treewide: use full path to gpio/gpio_esp32.h header [Peter Bigot/Carles Cufí]
74dd12bd7f4 treewide: use full path to gpio.h header [Peter Bigot/Carles Cufí]
a539fc6b730 treewide: use full path to flash.h header [Peter Bigot/Carles Cufí]
e35c8962787 treewide: use full path to entropy.h header [Peter Bigot/Carles Cufí]
ee35fab6f7d treewide: use full path to counter.h header [Peter Bigot/Carles Cufí]
6a964663b1c treewide: use full path to console/uart_pipe.h header [Peter Bigot/Carles Cufí]
f780247d8a6 treewide: use full path to console/uart_mcumgr.h header [Peter Bigot/Carles Cufí]
47e62276ff2 treewide: use full path to console/ipm_console.h header [Peter Bigot/Carles Cufí]
0b0d2e640be treewide: use full path to clock_control/stm32_clock_control.h header [Peter Bigot/Carles Cufí]
4147188bbbf treewide: use full path to clock_control/arm_clock_control.h header [Peter Bigot/Carles Cufí]
bbb00d0eb70 treewide: use full path to clock_control.h header [Peter Bigot/Carles Cufí]
0a81465554c treewide: use full path to can.h header [Peter Bigot/Carles Cufí]
19381a7e121 treewide: use full path to adc/lmp90xxx.h header [Peter Bigot/Carles Cufí]
dfd293a5c3e treewide: use full path to adc.h header [Peter Bigot/Carles Cufí]
2802fa4e6d0 treewide: avoid address-of-compound-literal idiom in headers [Peter A. Bigot/Carles Cufí]
6ade7208513 treewide: avoid use of unsupported C++ specifiers [Peter A. Bigot/Maureen Helm]
3bcd1880688 treewide: fix typos [Antony Pavlov/Kumar Gala]

@kartben
Copy link
Collaborator

kartben commented Apr 4, 2024

not sure this is needed, using "treewide:"

this is becoming a pattern in many PRs and you have to look closely to spot this. We do not have a preset list of allowed prefixes and I do not think we should have, detecting this and preventing "treewide" in the compliance check is still useful.

Right, but isn't the real issue that "treewide: ..." on its own should be banned, but not e.g. "treewide: flash: ...".
That git log you just posted is actually IMO demonstrating that there might be times where one might want to look back at "what was this recent treewide change I vaguely remember?"?

@kartben
Copy link
Collaborator

kartben commented Apr 4, 2024

just re-read the suggested fix, I guess "flash: treewide: ..." would still be allowed

kartben
kartben previously approved these changes Apr 4, 2024
Comment on lines 101 to 102
elif title.startswith('treewide'):
return [RuleViolation(self.id, violation_message, title)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is appending a fixed expression to what is otherwise a generic check (named like a specific one, but has a configuration https://github.com/zephyrproject-rtos/zephyr/blob/main/.gitlint#L28-L29 that allows extending well beyond "subsystem"), now the check naming and usage are misleading (see the error message)

I think this check should either be in its own gitlint class should be implemented in the existing config, but then the message should still be changed to reflect the new meaning

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the message is still valid: Commit title does not follow [subsystem]: [subject], treewide is not a subsystem.
Anyways, update to use previous regex.

@@ -95,7 +95,7 @@ class TitleStartsWithSubsystem(LineRule):
def validate(self, title, _commit):
regex = self.options['regex'].value
pattern = re.compile(regex, re.UNICODE)
violation_message = "Commit title does not follow [subsystem]: [subject] (and should not start with literal subsys:)"
violation_message = "Commit title does not follow [subsystem]: [subject] (and should not start with literal subsys or treewide)"
Copy link
Member

@fabiobaltieri fabiobaltieri Apr 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also change the class name (TitleStartsWithSubsystem) and title (title-starts-with-subsystem) while at it, maybe something like TitleCheck or TitleFormat?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? TitleStartsWithSubsystem is correct and exact.

Copy link
Member

@fabiobaltieri fabiobaltieri Apr 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because now it's TitleStartsWithSubsystemOrTreewide and how it's implement is more like "check the title against a regexp"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it checks that you start with a : and verifies that some commonly made mistakes, i.e. use literal subsys and now treewide are not being made.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok but then why keep

class TitleStartsWithSubsystem(LineRule):
    name = "title-starts-with-subsystem"

rathern than use a generic name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok but then why keep

class TitleStartsWithSubsystem(LineRule):
    name = "title-starts-with-subsystem"

Because this check does nothing but verify that your title starts with a subsystem?

Copy link
Member

@fabiobaltieri fabiobaltieri Apr 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I find it awkward that the implementation does the opposite but I guess it still kinda works, let's go with it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it depends on how you read it - "starts with [a] sub-system" vs. "starts with the literal 'subsystem'".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I realized that that's probably how it was meant to be read after Anas comment

Treewide changes touching a single area or topic should have the
area/subsystem at the start of the commit message. Treewide is very
ambigous.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
@nashif nashif force-pushed the topic/gitlint/treewide branch from a0970cd to 2583b54 Compare April 4, 2024 15:41
@aescolar aescolar merged commit 66af7a6 into zephyrproject-rtos:main Apr 10, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Coding Guidelines Coding guidelines and style area: Continuous Integration Trivial Changes that can be reviewed by anyone, i.e. doc changes, minor build system tweaks, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants