aboutsummaryrefslogtreecommitdiff
path: root/b4/__init__.py
AgeCommit message (Collapse)Author
2022-09-02Fix dedupe on using cached threadsHEADmasterKonstantin Ryabitsev
We were not properly running dedupe on cached threads, so fix it by only caching post-dedupe messages. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-09-01mbox: accept arbitrary public-inbox URLsKonstantin Ryabitsev
When "b4 am" or "b4 mbox" is passed an arbitrary URL that matches a public-inbox scheme but that doesn't match the midmask URL, assume the user knows what they are doing and attempt to retrieve the mbox. Suggested-by: Philippe Blain <levraiphilippeblain@gmail.com> Link: https://msgid.link/f2b0f3c1-d98d-979d-1513-18f2491f4267@gmail.com Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-09-01trailers: improve debugging of mismatched trailersKonstantin Ryabitsev
When we're adding a mismatched trailer, tell us why it hasn't been accepted. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-09-01Fix regression that resulted in ignored -pKonstantin Ryabitsev
Looks like at some point we started ignoring the -p flag, so restore this to the expected functionality Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-09-01ez: add b4 -F to allow (re-)creating branches from threadsKonstantin Ryabitsev
It is now possible to create a b4-tracked branch from an arbitrary thread (or from a previously sent b4-tracked series): b4 prep -F [msgid-of-the-series] Example: $ b4 prep -F 20220901194310.115427-1-tony.luck@intel.com Grabbing thread from lore.kernel.org/all/20220901194310.115427-1-tony.luck%40intel.com/t.mbox.gz Checking attestation on all messages, may take a moment... --- ✓ [PATCH 1/3] EDAC/skx_common: Use driver decoder first ✓ [PATCH 2/3] EDAC/skx_common: Make output format similar ✓ [PATCH 3/3] EDAC/i10nm: Add driver decoder for Ice Lake and Tremont CPUs --- ✓ Signed: DKIM/intel.com --- Created new branch b4/edac_improve_memory Applying 3 patches --- Applying: EDAC/skx_common: Use driver decoder first Applying: EDAC/skx_common: Make output format similar Applying: EDAC/i10nm: Add driver decoder for Ice Lake and Tremont CPUs --- NOTE: any follow-up trailers were ignored; apply them with b4 trailers -u This makes it easier to start tracking pre-existing series with b4 prep. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-09-01trailers: ignore non-recognized link trailersKonstantin Ryabitsev
If a link contains a '@', we wrongly consider it a person-trailer. Ignore any URL-containing trailers that we don't explicitly recognize. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-08-31Fix regression with b4 trailers -uKonstantin Ryabitsev
Fixes regression introduced by trailers refactor. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-08-31Fix regression incorrectly reporting mismatchesKonstantin Ryabitsev
Add a missing continue that caused incorrectly reported trailer mismatches. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-08-31Refactor how we handle trailersKonstantin Ryabitsev
With the addition of b4 trailers it became pretty obvious that the way we originally implemented trailers didn't age well. This refactor does the following: - introduces LoreTrailer class to replace passing trailers as tuples - reimplements trailer-order with strict adherence to chain-of-custody rules - adds tests to most common trailer follow-up/ordering cases Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-08-30Implement sending mail via local commandKonstantin Ryabitsev
The git-send-email configuration allows smtpserver to be defined as a path to a local sendmail-like command. Implement the same logic in b4, allowing fuller compatibility with git-send-email. Suggested-by: Maxime Ripard <maxime@cerno.tech> Link: https://msgid.link/20220830122217.h52zswusnlb3iggq@meerkat.local Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-08-29Improve sendemail identity handlingKonstantin Ryabitsev
The sendemail sections are supposed to be fall-throughs where a named section overrides the values provided by the global section. This implements the required logic to be compliant with git. Suggested-by: Rob Herring <robh@kernel.org> Link: https://msgid.link/20220825182506.1449442-1-robh@kernel.org Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-08-29Force CRLF lineseps only right before sending via smtpKonstantin Ryabitsev
We could be sending the patches via a web endpoint, for which we don't need to force CRLF line endings. Convert into CRLF only immediately before sending the message out via smtp. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-08-23ez: move the RESEND prefix into --resend switchKonstantin Ryabitsev
For UX reasons, make --resend a separate switch instead of operating on the --prefixes RESEND logic. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-08-23ez: only use web endpoint when sending patchesKonstantin Ryabitsev
Force the use of smtp server when sending anything other than patches (e.g. b4 ty automated responses). Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-08-19ez: implement large chunk of web endpoint submissionKonstantin Ryabitsev
This implements most of the web endpoint submission functionality. Completely undocumented and needs a lot more testing before it's useful, but we're getting close. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-08-15ez: do not bail on untracked files for prep tasksKonstantin Ryabitsev
We're not going to care about untracked files for most of b4 prep operations, so don't error out when they are present and we're running "is the tree clean" checks. Suggested-by: Maxime Ripard <maxime@cerno.tech> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-08-08ez: chdir to toplevel when running get_maintainerKonstantin Ryabitsev
The scripts expect to be running from the toplevel directory, so make sure to switch back to git topdir before running get_maintainer.pl Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-07-27ez: implement tip-commit strategyKonstantin Ryabitsev
First go at implementing the tip-commit strategy. It shares a lot with the 'commit' strategy, but there are gotchas for situations where the cover letter commit is suddenly not the tip commit any more (rebase, new commits, etc). Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-07-26ez: another overhaul of commands and flagsKonstantin Ryabitsev
Another, hopefully final overhaul of commands and flags: - "b4 ez-series" is now "b4 prep" - "b4 ez-trailers" is now "b4 trailers" - "b4 ez-send" is now "b4 send" I've also split on-disk output into two different commands: b4 prep --format-patch <outdir>: does not set To/Cc and doesn't do any From magic. In effect, it's as close as it gets to git format-patch output compatibility. b4 send --dry-run -o <outdir>: generates the messages exactly as they are about to be sent, then writes them out to the directory specified. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-07-26ez-send: fix To: inclusion and address collectionKonstantin Ryabitsev
Fix a logic bug that prevented the To: header from being added on --dry-run and do a better job making sure the addresses are valid and sane. Reported-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-07-22Fix regression introduced by ez-trailers workKonstantin Ryabitsev
I need to refactor the entire approach to trailers so we stop passing around tuples. It made sense at the time, but now it's just a source of bugs. Reported-by: Mark Brown <broonie@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-07-20ez: refactor based on initial feedbackKonstantin Ryabitsev
Significant refactor of (formerly) "b4 submit" based on initial feedback: 1. Split "b4 submit" into three different commands: - ez-series: for managing the series cover letters, tracking info, etc - ez-trailers: for retrieving trailers and updating commits (works on any branch, not just ez-series branches) - ez-send: for sending branches managed by ez-series 2. Refactor to support multiple cover letter strategies: - the default "commit" strategy that keeps the cover letter in an empty commit (should be backwards-compatible with "b4 submit") - the non-invasive "branch-description" strategy that keeps the cover letter in the branch.branchname.description configuration setting and tracking in branch.branchname.b4-tracking - the not-yet-implemented "tag" strategy that mimics the behaviour of git-publish The strategy can be set via b4.ez-cover-strategy variable, e.g. in your .gitconfig: [b4] ez-cover-strategy = branch-description Note, that converting from one strategy to another doesn't work and will probably explode in weird ways right now. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-07-19submit: reverse order returned by rev-listKonstantin Ryabitsev
git-rev-list returns patches in reverse chronological order by default, which is the opposite of what we need. Add a --reverse to the call to get the expected behaviour. Reported-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Link: https://lore.kernel.org/tools/87ilnti947.fsf@baylibre.com/ Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-07-15Fixes when working with utf-8 contentKonstantin Ryabitsev
When using set_payload(), we should pass along the charset as well, otherwise we run into trouble when converting to/from bytes again. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-07-15Initial implementation of b4 submitKonstantin Ryabitsev
This is the first rough implementation of "b4 submit". Currently implemented: - b4 submit --new : to start a new branch - b4 submit --edit-cover : to edit the cover message - b4 submit --update-trailers : to receive latest trailer updates from the mailing lists - b4 submit --send : sends the messages using existing git.sendemail configs For details, see "b4 submit --help". Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-06-27Ignore non-ascii follow-up trailersKonstantin Ryabitsev
The trailer *names* should always be ascii. While it is possible to imagine that some project would have non-ascii trailer names like: Signalé-par: Developpeur Un <d1@example.com> Co-développé-avec: Developpeur Deux <d2@example.com> Nonetheless, I am not aware of any project doing this, and this allows us to weed out a bunch of false-positives from bad forwards. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-06-27Move Signed-off-by below Link trailer when running with -slKonstantin Ryabitsev
Chain-of-custody order requires that Signed-off-by closes the list of added trailers. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-06-27Remove support for trailer-orderKonstantin Ryabitsev
Per discussion on the mailing lists, reordering trailers is almost never the right decision, so remove support for trailer ordering completely. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-06-21Dedupe msgid listKonstantin Ryabitsev
We don't want to use the set() here, since we want to preserve the order, so use an auxiliary set for dupe tracking. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-06-21Initial patchwork integration supportKonstantin Ryabitsev
A lot of maintainers use patchwork alongside b4, to make it easier to track patches and rely on some CI integration. This commit adds some basic patchwork integration: - on "b4 am", "b4 shazam", "b4 pr" we will mark the relevant patchwork entries as "Under Review" - on "b4 ty" we can set these patches as "Accepted" - on "b4 ty -d" we can set them as "Deferred" To make it work, the following entries must be present in the repository used with b4: [b4] pw-key = (your API token) pw-url = https://patchwork.kernel.org pw-project = (your project, e.g. linux-usb) pw-review-state = under-review pw-accept-state = accepted pw-discard-state = deferred To get your patchwork API token, go to your patchwork profile page. The pw-accept-state and pw-discard-state can be overridden using the --pw-set-state flag to "b4 ty". E.g. if you wanted to mark the patches as "Not applicable": b4 ty -d 5 --pw-set-state not-applicable Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-06-17Prepare for 0.9.0 releasev0.9.0Konstantin Ryabitsev
It is time to roll out 0.9.0 for wider use. Update requirements to the latest supported and tested versions. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-06-16Allow breaking threads using --no-parentKonstantin Ryabitsev
It is a common request to be able to get a partial thread in case someone submitted an auxiliary standalone patch in the middle of a larger patch series. Passing the msgid of the start of the thread along with --no-parent should tell b4 to break the thread at the start of the message-id specified and only consider that message and its children. Suggested-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/tools/YpTI9lhCfA7shi6j@sirena.org.uk/ Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-06-15Cosmetic cleanups to make PyCharm happierKonstantin Ryabitsev
Minor nitpicking by PyCharm, but not completely unreasonable. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-06-15Improve identity matching for DKIMKonstantin Ryabitsev
Sometimes the DKIM record will have the full email address instead of just the @domainname.com part. For those cases, drop the local part so we don't falsely claim domain mismatching during b4-am runs. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-06-14Lowercase identities for comparisonKonstantin Ryabitsev
When performing attestor identity comparisons, lowercase email addresses and domain names for case-insensitive matching. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-06-14am: Fix broken guessbranch handlingRob Herring
b4's usage of git-log '--branches' option is broken. The option takes a glob pattern *only* and must have an '=', but b4 ends up passing '--branches <guessbranch>' to git-log. This will kind of work, but is not checking only 'guessbranch'. For example, these 3 commands all do something different: git log -1 --branches=master git log -1 --branches master git log -1 --branches=*aster A maintainer wanting to apply a patch or series likely has a small set of known branches they apply patches to. Using a glob pattern is not a good fit for that. Instead, allow --guess-branch to be repeated and to take fixed refs. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org> Link: https://lore.kernel.org/r/20220331195346.1384515-1-robh@kernel.org
2022-06-14Remove unnecessary lookup when /all/ is used in midmaskKonstantin Ryabitsev
On lore.kernel.org we provide a unified index of all mailing lists in /all/, which removes the need to perform a redirect lookup when querying by message-id. However, some public-inbox instances may not have that, so we still need to be able to fall back to that redirect lookup. Adapt a patch from Rob Herring to support both situations. Link: https://lore.kernel.org/tools/20220225031135.4136158-1-robh@kernel.org/ Suggested-by: Rob Herring <robh@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-02-01Allow whitespace at the start of non-wrapped trailersKonstantin Ryabitsev
Sometimes folks indent their trailers with whitespace, so relax the rules to recognize this situation. In theory, this shouldn't introduce false-positives. Suggested-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20211214214327.4003631-1-robh@kernel.org Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-11-02Reimplement unicode control character logicKonstantin Ryabitsev
Instead of hardcoding the logic to bail at all presence of control characters, soften it a bit to only error out when we see the presence of Cfs in the absence of any other character from a non-latin character set in the same line. Additionally, show exactly where the Cfs were found when printing out the error message. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-11-01mbox: initial support to check for unicode control charsKonstantin Ryabitsev
Implement initial support for checking if the patch message contains unicode control characters that can be used to trick code reviewer into accepting maliciously formatted code. Link: https://lore.kernel.org/tools/20211101175020.5r4cwmy4qppi7dis@meerkat.local/ Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-11-01ty: fix problems with smtplib and 8BITMIMEKonstantin Ryabitsev
There appears to be a bug in smtplib that doesn't properly support 8-bit content even when upstream SMTP gateway supports 8BITMIME (they all do, it's not 90s any more). Work around this by passing the message payload as bytes instead of string. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-10-19Initial implementation of native mail sendingKonstantin Ryabitsev
I'm felling comfortable that "b4 ty" is sufficiently mature at this point to implement sending thank-yous directly. This is only the initial implementation that covers only the very basic parts of git's sendemail configuration options, but this should actually cover 90% of cases if not more. One important caveat -- I moved the "b4 ty -s" flag to be "b4 ty -t" in order to disambiguate it from the capital -S (that actually does the sending). Since "b4 ty" is still marked as an experimental feature, I feel we can do this without much impact. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-10-07validate: Use patatt's configured keyring as fallbackKees Cook
If b4 doesn't have an explicit keyringsrc configured, attempt to fetch it from patatt configuration instead. This avoids some very confusing situations where patatt would validate and b4 would reject. (I had an expired pubkey in my gpg default keyring, but the same pubkey had an updated expiration date in patatt's keyring.) Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org> Link: https://lore.kernel.org/r/20211007165551.2312946-1-keescook@chromium.org
2021-09-30shazam: implement custom merge message templatesKonstantin Ryabitsev
Allow people to set up their own preferred merge templates, using the netdev standard as default. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-09-21Add "b4 shazam" that is like b4 am + git amKonstantin Ryabitsev
By popular demand, provide a way to apply series straight to a git repository. By default, we're still going the safest possible route: - create a sparse worktree consisting just of the files being modified - run "git am" against the temporary worktree - if "git am" went well, fetch from the temporary worktree into our current tree and leave everything in FETCH_HEAD - unless we're running "b4 shazam -A" in which case we just apply to the current HEAD (exact equivalent of b4 am -o- | git am) Further changes to come based on feedback. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-09-01Up version to 0.8.0 and prep for relasev0.8.0Konstantin Ryabitsev
New version of lore.kernel.org is live today, so release the version of b4 that works best with it. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-08-25Normalize linebreaks when reconstituting bodyKonstantin Ryabitsev
When generating am-ready patch series, separate each standard body part with a single pair of newlines regardless of how many the original message contained. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-08-18Remove kludges that were needed before /all/Konstantin Ryabitsev
Extindex allows us to get rid of a couple of kludges: - we no longer need to manually backfill, as /all/ contains all sources - we can just query /all/ for new series Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-08-17Move dedupe code into central locationKonstantin Ryabitsev
We want to dedupe all threads we retrieve from public-inbox, so do this in the central place instead of only when doing get_strict_tread(). Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-08-17Reimplement deduping based on list-id preferenceKonstantin Ryabitsev
Instead of relying on DKIM validation, use list-id preference when dealing with multiple messages matching the same message-id. We may end up adding an attestation check to it as well in the future. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>