diff mbox series

[1/2] prep: add --check option to run necessary patch check

Message ID 20240319045332.2304950-1-Frank.Li@nxp.com (mailing list archive)
State New
Headers show
Series [1/2] prep: add --check option to run necessary patch check | expand

Commit Message

Frank Li March 19, 2024, 4:53 a.m. UTC
This just run script/tools/checkpatch.pl

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 b4/command.py |  1 +
 b4/ez.py      | 15 +++++++++++++++
 2 files changed, 16 insertions(+)

Comments

Konstantin Ryabitsev April 12, 2024, 9:09 p.m. UTC | #1
On Tue, Mar 19, 2024 at 12:53:31AM -0400, Frank Li wrote:
> This just run script/tools/checkpatch.pl

Hello:

Thank you for your contribution. I didn't end up taking it, because I 
wanted to make it more generic and less tied to the kernel. However, 
there is now very similar functionality in the current master that can 
be invoked with "b4 prep --check".

It's not yet a complete feature, but any feedback is welcome.

-K
Frank Li April 15, 2024, 9:33 p.m. UTC | #2
On Fri, Apr 12, 2024 at 05:09:43PM -0400, Konstantin Ryabitsev wrote:
> On Tue, Mar 19, 2024 at 12:53:31AM -0400, Frank Li wrote:
> > This just run script/tools/checkpatch.pl
> 
> Hello:
> 
> Thank you for your contribution. I didn't end up taking it, because I 
> wanted to make it more generic and less tied to the kernel. However, 
> there is now very similar functionality in the current master that can 
> be invoked with "b4 prep --check".

Can you point me the functionality name?

Frank

> 
> It's not yet a complete feature, but any feedback is welcome.
> 
> -K
Konstantin Ryabitsev April 16, 2024, 8:09 p.m. UTC | #3
On Mon, Apr 15, 2024 at 05:33:29PM -0400, Frank Li wrote:
> On Fri, Apr 12, 2024 at 05:09:43PM -0400, Konstantin Ryabitsev wrote:
> > On Tue, Mar 19, 2024 at 12:53:31AM -0400, Frank Li wrote:
> > > This just run script/tools/checkpatch.pl
> > 
> > Hello:
> > 
> > Thank you for your contribution. I didn't end up taking it, because I 
> > wanted to make it more generic and less tied to the kernel. However, 
> > there is now very similar functionality in the current master that can 
> > be invoked with "b4 prep --check".
> 
> Can you point me the functionality name?

I'm not quite sure what you mean. You should be able to just run "b4 
prep --check" to use it (with the latest master). E.g.:

  $ b4 prep --check
  Checking patches using:
	/home/user/work/git/linux/scripts/checkpatch.pl -q --terse --no-summary --mailback --showfile
  ---
  ● 0e77d0387477: serial: exar: adding missing CTI and Exar PCI ids
  ● d60ea7cc5b31: serial: exar: add support for reading from Exar EEPROM
  ● c78b0d54faac: serial: exar: add support for config/set single MPIO
  ● 32bd8299e6d3: serial: exar: add optional board_setup function
  ● 656acc105c50: serial: exar: add some CTI helper functions
	● checkpatch.pl: drivers/tty/serial/8250/8250_exar.c:606: WARNING: 'transciever' may be misspelled - perhaps 'transceiver'?
	● checkpatch.pl: drivers/tty/serial/8250/8250_exar.c:612: WARNING: 'transciever' may be misspelled - perhaps 'transceiver'?
	● checkpatch.pl: drivers/tty/serial/8250/8250_exar.c:652: WARNING: 'interupts' may be misspelled - perhaps 'interrupts'?
  ● dfda64f51bcc: serial: exar: add CTI board and port setup functions
	● checkpatch.pl: drivers/tty/serial/8250/8250_exar.c:1147: WARNING: 'interupts' may be misspelled - perhaps 'interrupts'?
  ● 32ea19edf0da: serial: exar: fix: fix crash during shutdown if setup fails
  ---
  Success: 5, Warning: 4, Error: 0

Hope this helps.

-K
diff mbox series

Patch

diff --git a/b4/command.py b/b4/command.py
index f4516b2..5d3bbc7 100644
--- a/b4/command.py
+++ b/b4/command.py
@@ -291,6 +291,7 @@  def setup_parser() -> argparse.ArgumentParser:
                          help='Force revision to be this number instead')
     sp_prep.add_argument('--set-prefixes', metavar='PREFIX', nargs='+',
                          help='Extra prefixes to add to [PATCH] (e.g.: RFC mydrv)')
+    sp_prep.add_argument('--check', action='store_true', default=False, help='Run necessary check before send patches')
 
     spp_g = sp_prep.add_mutually_exclusive_group()
     spp_g.add_argument('-p', '--format-patch', metavar='OUTPUT_DIR',
diff --git a/b4/ez.py b/b4/ez.py
index 9207282..bcf6363 100644
--- a/b4/ez.py
+++ b/b4/ez.py
@@ -2181,6 +2181,18 @@  def set_prefixes(prefixes: list) -> None:
     else:
         logger.info('No changes to extra prefixes.')
 
+def prep_check_patch() -> None:
+    logger.info('Run check patch.')
+    base_commit, stc, endc, oneline, shortlog, diffstat = get_series_details()
+    topdir = b4.git_get_toplevel()
+    getcheckpatch = os.path.join(topdir, 'scripts', 'checkpatch.pl')
+    cmdargs = list();
+    cmdargs.append(getcheckpatch)
+    cmdargs.append('-g')
+    cmdargs.append(stc + '..' + endc)
+    ret = subprocess.run(cmdargs)
+    if ret.returncode > 0:
+        logger.critical('CRITICAL: Check patch failure')
 
 def cmd_prep(cmdargs: argparse.Namespace) -> None:
     check_can_gfr()
@@ -2245,6 +2257,9 @@  def cmd_prep(cmdargs: argparse.Namespace) -> None:
     if cmdargs.auto_to_cc:
         auto_to_cc()
 
+    if cmdargs.check:
+        prep_check_patch()
+
     if cmdargs.edit_cover:
         return edit_cover()