summaryrefslogtreecommitdiff
path: root/b4/__init__.py
AgeCommit message (Collapse)Author
2020-05-25Prepare for 0.5.0v0.5.0Konstantin Ryabitsev
I think it's time to have more people poking at the diff functionality. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-25Backfill series before diffing themKonstantin Ryabitsev
Make sure we a) attempt to backfill the series if they are incomplete, b) error out if the series is incomplete anyway Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-25Add -3 to "b4 am" to prep for a 3way mergeKonstantin Ryabitsev
The original code used for b4 diff was to prepare for a 3-way merge by making sure that all blob indexes exist in the local repo. Add this functionality to "b4 am" and document all the features added in the 0.5.0 branch. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-22Add ability to diff arbitrary mbox filesKonstantin Ryabitsev
Sometimes we are unable to properly look up previous series -- usually because the cover letter title changes. For those cases, it is now possible to diff two arbitrary mbox files prepared with "b4 am -T". There's also a smattering of other fixes in there because I'm too lazy to properly stage my patches. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-19Display range-diff by defaultKonstantin Ryabitsev
Don't make developers do copy-pasting unnecessarily. Switch to outputting the diff by default, with flag options to save to file or just show what needs to be done. Additionally, adds caching to lookups and remember previously generated fake-am ranges so we don't continuously generate loose objects on repeat runs. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-15Initial implementation of b4 diffKonstantin Ryabitsev
Based on feedback from Jason Gunthorpe, implement diffing of series by creating fake git-am commit ranges. Here's an easy example: b4 diff 20200511192156.1618284-1-mic@digikod.net Suggested-by: Jason Gunthorpe <jgg@ziepe.ca> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-13Don't fail when a message uses a weird charsetKonstantin Ryabitsev
Found via auto-testing in: https://lore.kernel.org/linux-sgx/20200421215316.56503-13-jarkko.sakkinen@linux.intel.com/raw This is wrong on many levels: Content-Type: text/plain; charset=a Assume utf-8 when something like this happens and don't fail. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-13Fix crasher for incomplete threadsKonstantin Ryabitsev
Don't crash if the message in the References: is not available in the thread. Reported-by: Bjorn Helgaas <helgaas@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-07Add -P,--cherry-pick option to "b4 am"Konstantin Ryabitsev
This lets someone select a subset of patches in a series, e.g.: b4 am -P 1-3,5,7- [msgid] Suggested-by: Heiko Stübner <heiko@sntech.de> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-07Switch ty -s and -d to allow friendly rangesKonstantin Ryabitsev
Instead of insisting that people put in specific numbers, allow them to specify ranges, such as: b4 ty -s 1-3,5,7- Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-07Do not crash when thread is incompleteKonstantin Ryabitsev
Do not try to calculate indexes on a missing patch in an incomplete thread. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-07Remove QP encoding when getting fromnameKonstantin Ryabitsev
Make sure we get the clean header value when we store fromname. Link: https://linux.kernel.org/g/tools/message/142 Reported-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-01Check if mbox applies to current treeKonstantin Ryabitsev
Check if all patches in the mbox would apply cleanly to the current tree: - find index hash..hash information in each patch - check if git-hash-object shows exact same hashes for the current tree - if not, try the last 10 tags to see if any of them would be a good base-commit for the patch/series Not sure how useful the latter part it, but it hopefully shouldn't slow down regular operations, so I'm going to leave it in for now. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-27Parse body parts into usual chunksKonstantin Ryabitsev
Do a better job parsing a patch message into usual body parts: - git headers (From:, Subject:, Date:) - commit message - trailers - basement (under the ---\n) - signature (under the --\s\n) This allows us to create better reply quotes. Reported-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-24Set version to 0.5.0-devKonstantin Ryabitsev
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-24Prepare for 0.4.0 releaseKonstantin Ryabitsev
It's time to graduate to 0.4.0 with these features. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-20Use the cover for backfills when availableKonstantin Ryabitsev
When we have a cover letter, use that for backfill purposes, instead of finding the first non-None patch. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-20Support file delete patches and binary patchesKonstantin Ryabitsev
Git's file delete patches don't contain hunks, so we weren't properly processing them for attestation (and for b4 am). While fixing that, I also added attestation support for binary patches. Reported-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-15Properly deal with diffs that delete all linesKonstantin Ryabitsev
We weren't properly handling special diffs that deleted entire file contents (e.g. by deleting a file). Reported-by: Mark Brown <broonie@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-15Don't break on @@ -N,N +N @@ diff linesKonstantin Ryabitsev
When a commit is a new file with only one line, the diff output is different, so handle it without breaking. Reported-by: Mark Brown <broonie@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-15Get info from gecos if we don't have user.nameKonstantin Ryabitsev
Git gets user.name from gecos if it's not specified in user.name, so let's do the same thing. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-15Switch to using patchwork-compatible hashesKonstantin Ryabitsev
Using strict attestation hashes for auto-thankinator is problematic, because "git am" uses a certain degree of fuzzing, so when we try to find applied patches by running "git diff" on actual commits, line counts may not be bit-for-bit identical. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-10Use ~/.signature if it exists for tpt defaultsKonstantin Ryabitsev
If we find a ~/.signature, then use it for making a default ${signature} value, otherwise make a "Name <email>" boring one. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-10Add summaries to default templatesKonstantin Ryabitsev
They are much more useful if b4.thanks-commit-url-mask is set, but even without them this will list all subjects and corresponding commit IDs. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-09Add b4 ty that aims to simplify common feedbackKonstantin Ryabitsev
New experimental feature that aims to simplify a very common "thanks, applied" kind of feedback often expected of maintainers. Still needs documentation to explain its usage. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-07Use trailers from old revisions if no changesKonstantin Ryabitsev
If we have multiple versions of patch series in the same thread and someone adds a follow-up trailer to a patch in v1, but doesn't do it for the same *exact* patch in v2, then we carry over that trailer from v1 to v2. We use attestation hashes for this purpose, so all patch/metadata must be exact in order for the trailer to be reused. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-07Better deal with urlescaped msgidsKonstantin Ryabitsev
Message-IDs that are using escaped characters are breaking our lookup due to the refactoring that was necessary for backfilling. This should help deal with such cases. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-06Backfill missing threads from other lore listsKonstantin Ryabitsev
When we query by message-id, sometimes the list that is returned is not the best one to use, because it is lossy. Look at other addresses in the to/cc fields, and if we find another list address that is also backed up on lore.kernel.org, then attempt to backfill missing messages from those lists, until the entire series is complete. This should become obsolete in the future once public-inbox gains ability to return a thread sourced from multiple lists/feeds, but this should be a useful stop-gap measure to help developers in the meantime. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-03Recognize when reroll info is only in 1st patchKonstantin Ryabitsev
Sometimes this happens: [PATCH v2 1/N] [PATCH 2/N] [PATCH 3/N] [PATCH 4/N] Properly recognize such cases and version all patches threaded under the first one as v2. Reported-by: Amit Kucheria <amit.kucheria@gmail.com> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-30Clean up stray debug dataKonstantin Ryabitsev
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-30Decode headers into utf-8 from QPKonstantin Ryabitsev
Since we aren't planning on sending any of this as actual emails, convert EVERYTHING into utf-8 before writing messages, including QP-escaped 7-bit headers. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-30Add attestation checks for b4 prKonstantin Ryabitsev
We now use similar subroutines for checking signatures on FETCH_HEAD as we do for patch attestation, making it a convenient operation during the fetch stage: $ b4 pr 202003292114.2252CAEF7@keescook Looking up https://lore.kernel.org/r/202003292114.2252CAEF7@keescook Grabbing thread from lore.kernel.org Looking at: [GIT PULL] seccomp updates for v5.7-rc1 Fetching https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git tags/seccomp-v5.7-rc1 --- [✓] Attestation-by: Kees Cook <keescook@chromium.org> (pgp: 8972F4DFDC6DC026) --- Successfully fetched into FETCH_HEAD Hopefully, I didn't introduce too many bugs into patch attestation, since I had to rewrite the backend a bit to work for both native git operations and patch attestation calls. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-30PR: fix when gitdir is specified via -gKonstantin Ryabitsev
Fix some leftover bugs from prototyping stage when we were always assuming to run from a checkout. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-27We do want to use a list when sorting trailersKonstantin Ryabitsev
Switching to using sets for all trailer management resulted in trailer order being non-deterministic for trailers with the same title. Switch back to using lists where it makes a difference. Reported-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-27Make cache locations project-specificKonstantin Ryabitsev
When we use a specific project either via -p or via parsing the full lore URL, don't use the generic lookup cache location. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-26Add initial "b4 pr" command setKonstantin Ryabitsev
While working on "pull-request exploder" stuff for achiving on lore.kernel.org, I realized that this may be a useful set of features for developers as well, so here is a very simple framework for handing pull requests. Examples: b4 pr <msgid> - downloads that message - parses the pull request - checks that the remote tip is where the message says it should be - makes sure the base-commit is present in the tree - makes sure the tip commit isn't already in one of the branches - checks if FETCH_HEAD already is at that commit - if the above two checks pass, performs a git fetch b4 pr --check <msgid> Runs all of the checks above, but doesn't perform the actual fetch. Useful if you don't remember if you've already processed a pull request or not. b4 pr --explode <msgid> Runs basic sanity checks and then: - performs a git fetch - runs a "git format-patch" for base-commit..FETCH_HEAD - adds the same to/from/cc headers as in the pull request - properly threads each patch below the pull request - saves that into a <msgid>.mbox file The above is handy if you want to comment on something in a pull request and not have to hunt around for sender/cc information. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-25Ignore messages without plaintext contentKonstantin Ryabitsev
When a message contains no text/plain contents, then it's not anything we can use and we should toss them out early. Reported-by: Jason Donenfeld <Jason@zx2c4.com> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-24Warn when we are ignoring trailersKonstantin Ryabitsev
Provide a warning when we are ignoring trailers due to from/name mismatch between the headers and the body. Also provides a -S,--sloppy-trailers option to ignore all mismatches. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-24Up the version to 0.4.0-devKonstantin Ryabitsev
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-23Prepare for 0.3.4 releasev0.3.4Konstantin Ryabitsev
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-23Use set() for trailers instead of list()Konstantin Ryabitsev
There's never a situation where we can have legitimate duplicate entries for trailers, so switch to using sets. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-23Use more unique mbx names by adding subjectsKonstantin Ryabitsev
When the same person sends multiple sets of patches on the same day, we risk colliding between them. Use mbx names with cover/1st-patch subjects in them, to help disambiguate in such cases. Reported-by: Mark Brown <broonie@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-23Use a better single-sourced version setupKonstantin Ryabitsev
Fun read: https://packaging.python.org/guides/single-sourcing-package-version/ Anyway, I hated this way the least. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-20Add caching layerKonstantin Ryabitsev
Many lore.kernel.org operations can be repeated within quick succession of each-other (e.g. someone reruns a query with -t). This commit adds a caching layer that keeps lookups in local cache for 10 minutes (default). It can be made longer or shorter by editing the 'cache-expire' setting, or running "b4 am" with -C,--no-cache. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-20Improve brackets-within-brackets regexKonstantin Ryabitsev
The horrible things people do to their patch subjects continue to amaze me. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-19Properly handle blank lines in patchesKonstantin Ryabitsev
We don't need to strip() patches, because a) it introduces a problem if the patch has blank lines in it, and b) because it doesn't matter if there's anything trailing at the end. We still need better handling for obviously broken patches, but at least valid ones shouldn't cause problems. Reported-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-18Use b4.VERSION for setup.py version infoKonstantin Ryabitsev
No longer need to change version in both places. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-18Handle vN that only exists in the cover letterKonstantin Ryabitsev
There are special cases where we have: cover: [PATCH v3 00/NN] Foo \- [PATCH 01/NN] Patch 1 - [PATCH 02/NN] Patch 2 While the submitter *should* be setting "v3" in all patches, it's not uncommon to have that inferred from the cover letter. When cover letter is properly upthread from the patch that has an inferred v1 revision, we can check the revision on the cover letter and fix the patch revision to match. Reported-by: Mark Brown <broonie@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-18Check the age of attestationv0.3.3Konstantin Ryabitsev
If attestation is over 30 days older than the patch, then we refuse to accept it. This can be changed in configuration parameters by setting 'attestation-staleness-days' to a higher/lower value. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-17Up the version to 0.3.3-preKonstantin Ryabitsev
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>