test suite reviews and discussions
 help / color / mirror / Atom feed
* [PATCH] formatting_script: Add formatting script
@ 2022-03-02 18:42 ohilyard
       [not found] ` <CAHx6DYBRH5p9HCPg3Ogds6usRgT1nrSMXTKaHaODyqCRzKhSRw@mail.gmail.com>
  2022-03-16  6:29 ` Tu, Lijuan
  0 siblings, 2 replies; 3+ messages in thread
From: ohilyard @ 2022-03-02 18:42 UTC (permalink / raw)
  To: dts; +Cc: lijuan.tu, Owen Hilyard

From: Owen Hilyard <ohilyard@iol.unh.edu>

Added a formatting script to run black an isort with. By default, it
will run in the current working directory. If $1 is specified and not
either "-h" or "--help", it will run in that directory instead. This
does not allow checking for a git diff after formatting (for rejecting
patches in CI), but that should be fairly easy to implement in a wrapper
script.

Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
---
 format.sh | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100755 format.sh

diff --git a/format.sh b/format.sh
new file mode 100755
index 00000000..d35c0bf1
--- /dev/null
+++ b/format.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+
+function main() {
+    # The directory to work on is either passed in as argument 1,
+    # or is the current working directory
+    DIRECTORY=${1:-`pwd`}
+    LINE_LENGTH=88
+
+    isort \
+      --overwrite-in-place \
+      --profile black \
+      -j `nproc` \
+      --line-length $LINE_LENGTH \
+      --python-version auto \
+      $DIRECTORY
+
+    black \
+      --line-length $LINE_LENGTH \
+      --required-version 22.1.0 \
+      --target-version py38 \
+      --safe \
+      $DIRECTORY
+}
+
+function help() {
+  echo "usage: format.sh <directory>"
+}
+
+if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
+  help
+  exit 0
+fi
+
+main "$1"
+
-- 
2.30.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] formatting_script: Add formatting script
       [not found] ` <CAHx6DYBRH5p9HCPg3Ogds6usRgT1nrSMXTKaHaODyqCRzKhSRw@mail.gmail.com>
@ 2022-03-02 18:52   ` Owen Hilyard
  0 siblings, 0 replies; 3+ messages in thread
From: Owen Hilyard @ 2022-03-02 18:52 UTC (permalink / raw)
  To: dts; +Cc: Tu, Lijuan


[-- Attachment #1.1: Type: text/plain, Size: 116 bytes --]

Sorry for the double reply. The mailing list notified me that the file was
too large, so here's an xzipped version.

[-- Attachment #1.2: Type: text/html, Size: 143 bytes --]

[-- Attachment #2: 0001-Format-DTS.patch.xz --]
[-- Type: application/x-xz, Size: 778868 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] formatting_script: Add formatting script
  2022-03-02 18:42 [PATCH] formatting_script: Add formatting script ohilyard
       [not found] ` <CAHx6DYBRH5p9HCPg3Ogds6usRgT1nrSMXTKaHaODyqCRzKhSRw@mail.gmail.com>
@ 2022-03-16  6:29 ` Tu, Lijuan
  1 sibling, 0 replies; 3+ messages in thread
From: Tu, Lijuan @ 2022-03-16  6:29 UTC (permalink / raw)
  To: ohilyard, dts

Applied, thanks

> -----Original Message-----
> From: ohilyard@iol.unh.edu <ohilyard@iol.unh.edu>
> Sent: 2022年3月3日 2:43
> To: dts@dpdk.org
> Cc: Tu, Lijuan <lijuan.tu@intel.com>; Owen Hilyard <ohilyard@iol.unh.edu>
> Subject: [PATCH] formatting_script: Add formatting script
> 
> From: Owen Hilyard <ohilyard@iol.unh.edu>
> 
> Added a formatting script to run black an isort with. By default, it will run in the
> current working directory. If $1 is specified and not either "-h" or "--help", it will
> run in that directory instead. This does not allow checking for a git diff after
> formatting (for rejecting patches in CI), but that should be fairly easy to
> implement in a wrapper script.
> 
> Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
> ---
>  format.sh | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
>  create mode 100755 format.sh
> 
> diff --git a/format.sh b/format.sh
> new file mode 100755
> index 00000000..d35c0bf1
> --- /dev/null
> +++ b/format.sh
> @@ -0,0 +1,35 @@
> +#!/usr/bin/env bash
> +
> +function main() {
> +    # The directory to work on is either passed in as argument 1,
> +    # or is the current working directory
> +    DIRECTORY=${1:-`pwd`}
> +    LINE_LENGTH=88
> +
> +    isort \
> +      --overwrite-in-place \
> +      --profile black \
> +      -j `nproc` \
> +      --line-length $LINE_LENGTH \
> +      --python-version auto \
> +      $DIRECTORY
> +
> +    black \
> +      --line-length $LINE_LENGTH \
> +      --required-version 22.1.0 \
> +      --target-version py38 \
> +      --safe \
> +      $DIRECTORY
> +}
> +
> +function help() {
> +  echo "usage: format.sh <directory>"
> +}
> +
> +if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
> +  help
> +  exit 0
> +fi
> +
> +main "$1"
> +
> --
> 2.30.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-16  6:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-02 18:42 [PATCH] formatting_script: Add formatting script ohilyard
     [not found] ` <CAHx6DYBRH5p9HCPg3Ogds6usRgT1nrSMXTKaHaODyqCRzKhSRw@mail.gmail.com>
2022-03-02 18:52   ` Owen Hilyard
2022-03-16  6:29 ` Tu, Lijuan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).