Commit Graph

525 Commits

Author SHA1 Message Date
Simon Glass
39a4396362 patman: Update Commit to include the message
There is in fact a 'msg' member for Commit, set up by the
Patchstream._close_commit() function. Declare it in the docs and set it
to empty when the Commit is created.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-27 04:51:56 -07:00
Simon Glass
bca5edfcf6 checkpatch: Allow AI Co-developed-by without matching Signed-off-by
When a patch is co-developed with an AI assistant, the Co-developed-by
tag typically uses a noreply email address. Since Signed-off-by requires
a real person with a valid email address, skip the name/email mismatch
warning when the Co-developed-by email contains "noreply@".

Cover-letter:
checkpatch: Sync with Linux v6.18
This series syncs checkpatch.pl with Linux v6.18 and adds several
U-Boot-specific improvements:

- Fix patman's checkpatch message parsing for consecutive messages
- Allow test macros (UNIT_TEST, etc.) immediately after function close
- Allow AI Co-developed-by tags without requiring matching Signed-off-by
END

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-25 14:31:00 -07:00
Simon Glass
6ad7f66b1c checkpatch: Allow test macros immediately after function close
U-Boot test declarations (e.g., FS_TEST, UNIT_TEST) should immediately
follow the closing brace of the test function with no blank line.

Add an exception to the blank-line-after-declaration check for *TEST
macros, and add a new check that warns if there IS a blank line before
a test declaration macro.

Update the patman test to handle duplicate warnings now that message
parsing correctly separates consecutive checkpatch messages.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-25 14:31:00 -07:00
Simon Glass
925c5ee5da patman: Fix checkpatch message parsing for consecutive messages
Checkpatch.pl doesn't always output blank lines between messages. The
current parser splits on '\n\n' which fails to separate consecutive
messages, causing "Internal error: some problems lost" warnings.

Fix by splitting on message-starting patterns (ERROR:, WARNING:, CHECK:,
etc.) instead of blank lines.

Add a test that verifies consecutive messages are parsed correctly.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-25 14:31:00 -07:00
Simon Glass
8a12c56e54 checkpatch: Sync with Linux v6.18
Update checkpatch.pl from Linux v6.18, adding U-Boot-specific checks:

- Add --u-boot option to enable U-Boot-specific warnings
- Add debug/printf to $logFunctions
- Add u_boot_struct_name() for driver struct naming conventions
- Add u_boot_line() with checks for uclass, livetree API, commands,
  IS_ENABLED usage, strl* functions, CONFIG symbols, barred includes,
  fdt/initrd relocation, skip_board_fixup, and driver model schema

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-25 14:31:00 -07:00
Simon Glass
c3b2c14731 patman: Support autolink when some series are archived
Archived series currently cause an error when autolink is attempted. Add
a check to avoid this.

Series-to: u-boot
Signed-off-by: Simon Glass <sjg@chromium.org>
Series-links: 1:458284
2025-08-20 09:54:41 -06:00
Simon Glass
12a20d3122 patman: Correct parsing of branch names
The name 'x86a' must be parsed as a branch name, not as versio 86 of
branch 'x'. Correct the regex and add a test for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:54:41 -06:00
Simon Glass
a9ea16e399 patman: Allow using the first commit as series description
Sometimes series don't have a cover letter. Add a --use-commit option to
easily use the first commit's subject instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:54:41 -06:00
Simon Glass
e26ea124fb patman: Allow showing progress on archived series
Sometimes it is useful to include archived series in the progress report
so you can see all the work completed. Add a flag for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:54:41 -06:00
Simon Glass
16667556bd patman: Allow listing archived series
Sometimes it is useful to include archived series in the listing so you
can see which series could potentially be unarchived. Add a flag for
this.

Add a --include-archived option to the 'series ls' command for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:54:41 -06:00
Simon Glass
da1cdaf278 patman: Move split_name_version to patchstream
This function is needed by 'patman status', meaning that it must import
cser_helper which needs pygit2

Move it to patchstream so that pygit2 is not needed for the
'patman status' command.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:54:41 -06:00
Simon Glass
abb8470f86 patman: Avoid needing pygit2 for all subcommands
If pygit2 does not exist, patman refuses to work at all, but most
subcommands don't need it. Move the imports to resolve this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:54:41 -06:00
Simon Glass
5e8b30cd4c patman: Handle invalid characters in patch files
In some cases latin1 encoding may be used in source files. If
'high-ascii' are used, patman may report an error:

   UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf3 in
      position 1051: invalid continuation byte

Fix this by replacing these characters. This may cause the patch to fail
to apply, but at least it can be checked.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 07:41:19 -06:00
Simon Glass
f387937b46 patman: Drop hard-coded patchwork server
Since there is now a new server at patchwork.u-boot.org allow using this
if selected in the ~/.patman file.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 07:41:17 -06:00
Simon Glass
9407486df2 tools: Move to version 0.0.7
Update all tools to the new version, since there have been quite a lot
of changes recently.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-26 23:55:02 +12:00
Simon Glass
cafd1d6e7e patman: Add basic documentation for new features
Describe the new subcommands and how they should be used in a normal
workflow.

Note that the naming of branches is very rigid, or 'opinionated' in
marketing terms. Patman can track a single branch for each version of a
series and they must all be named the same, except for the
version-number suffix. Version 1 series have no suffix.

This description is fairly bare-bones but should be enough for some
initial testing and comments.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
c927775609 patman: Add tests for Cseries
Add various tests for the Cseries functionality, including both direct
and via-cmdline variants.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
351721439f patman: Implement the upstream subcommand
Add a command to allow managing the upstream tree. This is very basic
so far, only allowing setting the name and URL. Further work may allow
checking whether series apply cleaning on the upstream tree, etc.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
31b3b588d6 patman: Implement the series subcommand
Add a command to support management of series. These are local branches
which may have been sent to the mailing list, so may appear on the
patchwork server.

The new functionality uses a database, stored in a local file.

Various operations are supported:
   - add a new series
   - send a series and automatically link it with patchwork
   - 'increment' the version, to prepare to send an updated series
   - gather review/test tags from patchwork
   - check on progress, i.e. patches which are received new tags or
     comments
   - show comments on patches and cover letters

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
af99fb769d patman: Update send function to return whether it sent
Indicate whether 'git send-email' was actually called, so that we don't
bother waiting for patchwork to receive our series if it wasn't.

The 'git send-email' seems to always return a code of 0 even if nothing
was sent, so we cannot use clues there. Ideally we would watch the
output to determine which patches were sent and which not, but that is
left for another day.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
30b733403e patman: Support aliases for commands and subcommands
It is laborious to type long commands, so add some aliases to speed up
use of patman. For now, allow 'pw' for patchwork and 'st' for status.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
61e16bcadd patman: Implement the patchwork subcommand
Add a command to allow setting and getting the patchwork project. This
is needed so that patman can use the correct ID when talking to the
patchwork server.

To support testing, allow passing in the test database, patchwork
object and Cseries object. Fake versions can then easily be provided for
certain test cases.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
dac50cc025 patman: Improve Series support for patchwork links
Update Series with a way to better manage the Series-links lines in
patches. Use this in the 'status' subcommand instead of the existing
primitive method of expecting a link without a version prefix.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
1825f4542e patman: Introduce basic database support in Series
This class manages a series, i.e. a group of patches with a possible
cover letter. Add some properties for recording basic patchwork info,
including the database ID.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
7b7d3a2ed1 patman: Support returning the parsers to use
The parsing tests need to be able to try invalid arguments to make sure
that these are handled correctly. Provide a way to return the parsers
being used, as well as to pass in the parsers to use. This feature is
needed in test_series_no_subcmd(), for example.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
72122067b7 patman: Use -c to show patch comments
We chose -C as the flag to enable showing comments because -c was used
in 'patman send' to specify the patch count. Now that the 'send' parser
is separated we don't need to do this and it is OK to use the same flag
in a different subcommand.

We want to have a flag for cover-letter comments, so it makes most sense
to have -C for that and -c for patch comments. Update the latter.

Put this in a function since the new 'series' command will add this flag
too.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
13e3b5699a patman: Enhance implementation of file-based defaults
Patman allows defaults for its command-line flags to be read from a
file. The implementation of this does not fully work with subcommands,
since we don't want a default for those.

Also, it relies on being able to parse any sort of cmdline in order to
figure out the options that are available. But in some cases, the
cmdline may not parse, e.g. if there are required options, or
conflicting options.

Add a class which can be safely used to parse any cmdline, since it
allows execution to continue even when errors are obtained. Use this to
determine the defaults, being careful to skip sub/commands.

Another way to handle all of this would be to maintain the defaults
separately and insert them into the parser manually. For now, I'm not
sure which is best.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
5edcf586be patman: Enhance patchwork interface to support Cseries
Add various new requests to the Patchwork class, so we can obtain the
required information. This includes cover letters and comments.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
908e026e15 patman: Update status command support cover-letter info
Add support to the status module for reading and supporting cover
letters, including comments. Plumb this through to the patchwork module.
The actual support in the latter is not yet integrated.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
4f729e758b patman: Add a Cseries class
This is the main class for dealing with series, across branches and the
database.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
c97bf9191e patman: Add a helper for managing cseries
Add a module which includes helper functions for dealing with Cseries
objects.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
8853dae6c0 patman: Add a simple database implementation
For recording series information, patman needs a database. Add a module
which uses sqlite3 for this. It has a basic schema, enough to support a
series subcommand.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
0576fdf2e8 patman: Avoid touching the system or local config
Set the git variables to ensure that any local gitconfig is not used or
affected by the tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
2a72d57cfd patman: Add a fourth series for testing
Create one more series to use for testing. This one has four separate
patches.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
1145cef2d9 patman: Move common test code into a new module
The func_test file is quite large. In order to allow new tests to be
added to a separate file, move the common test code into a separate
class, to be inherited by other classes.

Drop unnecessary imports in func_test

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
5694ce93bd patman: Add a test for collecting a PATCH prefix
Add one more test for completeness, since this occurs commonly.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
fc91a400f4 patman: Use python3 with /usr/bin/env
If python2 is available then we must specify python3 here. Update the
test to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
1c35dcfcef patman: Deal with git safe-directory warning
When running tests where the .git directory is not owned by the current
user, various warnings are produced and the tests fail. This happens in
CI.

For patman itself, modify the gitutil.get_top_level() function to return
None in this case. Ensure that the warning is not shown, since it creates
about 1000 lines of output.

For checkpatch, the same warning is produced even though --no-tree is
given. Suppress that as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-24 05:26:46 +01:00
Simon Glass
20131bff66 patman: Support collecting all lines in the commit message
In some cases we want to collect all lines in the commit message so that
the commit can be recreated with the same message as before, or perhaps
with light filtering.

Add support for this.

Series-to: u-boot
Cover-letter:
patman: Minor improvements to prepare for series handling
This series includes a number of internal improvements to patman:
- Tidy-up of parsing
- Adjust how tests create the git tree
- Support for creating patches in a different git directory
- Faster determination of the upstream branch
- Ability to collect the body of a commit message as a series of lines
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-23 17:10:12 +01:00
Simon Glass
b7c0f7b0e6 patman: Tidy up function comments in the series module
This module is missing some comments, so add them.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-23 17:10:12 +01:00
Simon Glass
8158f46a25 patman: Move -H out of the send command
This is the help for the whole of patman, so move it to the start of the
control function, rather than being inside 'patman send'.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-23 17:10:12 +01:00
Simon Glass
5734b2b7bc patman: Move arguments for sent into the correct parser
Most of the arguments for the main parser are actually arguments for the
'send' parser. Move them there, in a separate function.

Fix a pylint warning for -D and the imports while here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-23 17:10:12 +01:00
Simon Glass
bf692cc795 patman: Split subparsers into their own functions
Simplify the main parser by moving subparser code into separate
functions. Fix a few pylint warnings while here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-23 17:10:12 +01:00
Simon Glass
4ceb95daab patman: Add tests for help
Add a few tests to make sure that help is provided when requested.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-23 17:10:12 +01:00
Simon Glass
5c5eb063bd patman: Split parser creation from parsing
Tests may want to parse their own arguments. Refactor the parser code to
support this and allow settings to receive arguments as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-23 17:10:12 +01:00
Simon Glass
6ade0733e9 patman: Correct some pylint and asyncio issues
Correct some pylint warnings in this file. Make use of the existing
asyncio event loop, instead of creating a new one, since this also
destroys it afterwards, making it unavailable for tests which want to
share an event loop. Use tools.write_file() to avoid a warning about
encoding.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-23 17:10:12 +01:00
Simon Glass
797cc447a4 patman: Use git to set up the test config
At present the branch information is dropped when writing the
configuration. It is easier to get git to set up the config anyway, so
update the test to do this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-23 17:10:12 +01:00
Simon Glass
329636499c patman: Clean up creation of the git tree
The test starts with the HEAD pointing to the wrong place, so that the
created files appear to be deleted. Fix this by resetting the tree
before tests start. Add a check that the tree is clean.

Update pygit2 so that the enums are available.
2025-05-23 17:10:12 +01:00
Simon Glass
41977a9541 patman: Use variables for series ID and title
Rather than hard-coding these values in the sample patches, use
variables so that we can refer to these in tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-23 17:10:12 +01:00
Simon Glass
23028aa1fe patman: Use .git as the git directory
In tests, the 'git' directory is a subdirectory of the temporary
directory. Rename it to '.git' so that git will automatically find it
when git operations are done in the temporary directory. Set up the
config before the first git operation, so that this works correctly.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-23 17:10:12 +01:00