diff mbox series

[b4,v2] ez: Add --use-web-endpoint arg to force web endpoint

Message ID 20230802-jag-add_web_switch-v2-1-2e789cf3e0a0@samsung.com (mailing list archive)
State Accepted
Headers show
Series [b4,v2] ez: Add --use-web-endpoint arg to force web endpoint | expand

Commit Message

Joel Granados via B4 Relay Aug. 2, 2023, 7:39 a.m. UTC
From: Joel Granados <j.granados@samsung.com>

Make it easier to prefer going through the web endpoint by adding an
argument that will force this path. This is for users that want to use
B4 for preparing and sharing patchsets over mail and need an argument to
activate the web endpoint whenever needed, but want to default to smtp
server for the rest.

Signed-off-by: Joel Granados <j.granados@samsung.com>
---
Changes in v2:
* Changed arg name from --web to --use-web-endpoint.
* Moved the argument to the main arguments group.
* Updated the doc so it still makes sense.
---
 b4/command.py             |  2 ++
 b4/ez.py                  |  4 +---
 docs/contributor/send.rst | 10 ++++++----
 3 files changed, 9 insertions(+), 7 deletions(-)


---
base-commit: 099c9b47b39b6076752b8c757872080fad8fae56
change-id: 20230801-jag-add_web_switch-42a4287768ed

Best regards,

Comments

Konstantin Ryabitsev Aug. 2, 2023, 4:07 p.m. UTC | #1
On Wed, 02 Aug 2023 09:39:41 +0200, Joel Granados wrote:
> Make it easier to prefer going through the web endpoint by adding an
> argument that will force this path. This is for users that want to use
> B4 for preparing and sharing patchsets over mail and need an argument to
> activate the web endpoint whenever needed, but want to default to smtp
> server for the rest.
> 
> 
> [...]

Applied, thanks!

[1/1] ez: Add --use-web-endpoint arg to force web endpoint
      commit: e8045d1353165cc065b2f1b180bf1b0846af510e

Best regards,
diff mbox series

Patch

diff --git a/b4/command.py b/b4/command.py
index 1ae73d2..71c1abd 100644
--- a/b4/command.py
+++ b/b4/command.py
@@ -130,6 +130,8 @@  def setup_parser() -> argparse.ArgumentParser:
                         help='Do not perform any network queries')
     parser.add_argument('--no-stdin', action='store_true', default=False,
                         help='Disable TTY detection for stdin')
+    parser.add_argument('--use-web-endpoint', dest='send_web', action='store_true', default=False,
+                        help="Force going through the web endpoint")
 
     subparsers = parser.add_subparsers(help='sub-command help', dest='subcmd')
 
diff --git a/b4/ez.py b/b4/ez.py
index 3799e07..e38827f 100644
--- a/b4/ez.py
+++ b/b4/ez.py
@@ -1459,10 +1459,8 @@  def cmd_send(cmdargs: argparse.Namespace) -> None:
         pathlib.Path(cmdargs.output_dir).mkdir(parents=True, exist_ok=True)
 
     sconfig = b4.get_sendemail_config()
-    # If we have an smtp server defined, always use that instead of the endpoint
-    # we may make this configurable in the future, but this almost always makes sense
     endpoint = None
-    if not sconfig.get('smtpserver'):
+    if not sconfig.get('smtpserver') or cmdargs.send_web:
         endpoint = config.get('send-endpoint-web', '')
         if not re.search(r'^https?://', endpoint):
             logger.debug('Endpoint does not start with https, ignoring: %s', endpoint)
diff --git a/docs/contributor/send.rst b/docs/contributor/send.rst
index 9be8d1c..8454f37 100644
--- a/docs/contributor/send.rst
+++ b/docs/contributor/send.rst
@@ -124,9 +124,10 @@  You should now be able to send patches via this web submission endpoint.
 
 Using your own SMTP server
 --------------------------
-B4 will use the ``sendemail`` section from your git configuration, but
-it only supports the most common subset of options. The vast majority of
-servers will only need the following settings::
+If there is a ``sendmail`` section in your git configuration, B4 will try use
+that by default instead of the web endpoint. Only the most common subset of
+options are supported. The vast majority of servers will only need the
+following settings::
 
     [sendemail]
        smtpServer = smtp.example.org
@@ -136,7 +137,8 @@  servers will only need the following settings::
        smtpPass = [omitted]
 
 You can also set up msmtp or a similar tool and specify the path to the
-``sendmail``-compliant binary as the value for ``smtpServer``.
+``sendmail``-compliant binary as the value for ``smtpServer``. You can force B4
+to use the web endpoint by using the ``--use-web-endpoint`` argument.
 
 Sending your patches
 --------------------