Skip to content

Generalize selection parser; add "attribution" command

Eric Sunshine requested to merge sunshineco/reposurgeon:es/attribution into master

This patch series adds a new attribution command to reposurgeon for inspecting, modifying, removing, and inserting commit and tag attributions. Documentation and tests are included.

Attribution selection is modeled after ed(1), just as reposurgeon event selection is so modeled. The series generalizes the existing selection parser for re-use, thus attributions can be selected with the same rich selection language used for event selection. As such, an attribution selection expression may be composed from attribution number, $, .. ranges, comma, (...) grouping, set operations | union, & intersection, and ~ negation, and function calls @min(), @max(), and so on. Attributions can also be selected by visibility set =C for committers, =A for authors, and =T for taggers, as well as /regex/ne matched against attribution name (/n), email address (/e), or both if flags are omitted.

A few examples to whet the appetite:

# inspect authors of all commits
attribution =A show

# change name of tagger of final tag
@max(=T) attribution =T set "Eric Sunshine"

# change email address of first author of commit :2
:2 attribution @min(=A) set sunshine@sunshineco.com

# delete all but the last author of all commits
=C attribution =A & ~@max(=A) delete

# add author after "esr@thyrsus", inferring name and date of
# new author from existing attributions (if possible)
2,4 attribution /esr/e & =A append sunshine@sunshineco.com

The series is composed of one minor and three major sections:

  • Patches 1 - 4 are minor cleanups, primarily dead-code removal.

  • Patches 5 - 28 generalize the selection expression parser so it can be repurposed for other use-cases; generic functionality is moved to new class SelectionParser.

  • Patches 29 - 52 convert the selection parser to a compile/evaluate paradigm, allowing a selection expression to be compiled once and evaluated multiple times rather than being evaluated as the expression is being parsed.

  • Patches 53 - 67 implement the new attribution command.

Although the series is quite lengthy, the patches have been carefully crafted for minimal review burden. Many patches in the second and third sections are pure textual relocations, and most remaining patches in those sections are tightly-focused simple and obvious code transformations. Patches implementing the attribution command are necessarily a bit more heavyweight, though still tightly-focused and easily digested.

Merge request reports