Message ID | 20230801-jag-add_web_switch-v1-1-a0021c1ee8c2@samsung.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | [b4] ez: Add a --web arg to force web endpoint | expand |
On Tue, Aug 01, 2023 at 05:03:36PM +0200, Joel Granados via B4 Relay wrote: > 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. Okay, that looks good to me, but can you please make two changes: > @@ -330,6 +330,8 @@ def setup_parser() -> argparse.ArgumentParser: > help='Initiate a new web authentication request') > ag_sendh.add_argument('--web-auth-verify', dest='auth_verify', metavar='VERIFY_TOKEN', > help='Submit the token received via verification email') > + ag_sendh.add_argument('--web', dest='send_web', action='store_true', default=False, > + help="Force the send command to go through the web endpoint") 1. It doesn't really belong in this argument group (it's just for setting up authentication and says so in the title). You can just put this switch with the main arguments, perhaps as the last entry. 2. Call it --use-web-endpoint instead of just --web Thanks! -K
On Tue, Aug 01, 2023 at 12:14:22PM -0400, Konstantin Ryabitsev wrote: > On Tue, Aug 01, 2023 at 05:03:36PM +0200, Joel Granados via B4 Relay wrote: > > 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. > > Okay, that looks good to me, but can you please make two changes: > > > @@ -330,6 +330,8 @@ def setup_parser() -> argparse.ArgumentParser: > > help='Initiate a new web authentication request') > > ag_sendh.add_argument('--web-auth-verify', dest='auth_verify', metavar='VERIFY_TOKEN', > > help='Submit the token received via verification email') > > + ag_sendh.add_argument('--web', dest='send_web', action='store_true', default=False, > > + help="Force the send command to go through the web endpoint") > > 1. It doesn't really belong in this argument group (it's just for > setting up authentication and says so in the title). You can just put this totally missed that :), thx for the feedback > switch with the main arguments, perhaps as the last entry. I have added it to the main args under --no-stdin. Now that it is in the main args, I'll change the argument documentation from "Force the send command to go through the web endpoint" to "Force going through the web endpoint". > 2. Call it --use-web-endpoint instead of just --web sure thing > > Thanks! > > -K
diff --git a/b4/command.py b/b4/command.py index 1ae73d2..15ca370 100644 --- a/b4/command.py +++ b/b4/command.py @@ -330,6 +330,8 @@ def setup_parser() -> argparse.ArgumentParser: help='Initiate a new web authentication request') ag_sendh.add_argument('--web-auth-verify', dest='auth_verify', metavar='VERIFY_TOKEN', help='Submit the token received via verification email') + ag_sendh.add_argument('--web', dest='send_web', action='store_true', default=False, + help="Force the send command to go through the web endpoint") sp_send.set_defaults(func=cmd_send) return parser 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..ca7f082 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 passing ``--web`` to the send command. Sending your patches --------------------