Package: git-trunk
Git Trunk based workflowAdds git-trunk commands that automates some common git procedures.Usage:git trunk <command>Possible commands:init: initialize trunk configuration to be used for other commands.start: create new branch specifying custom name or use patterns to fetch/filter remote branches. First match is used to create local branch.finish: finish active branch by merging it to trunk (then remove it).release: create tag with new release version.refresh: update trunk branch and rebase it on active branch.squash: squash commits on active branch.Code was tested usinggit version 2.25.1.Source code in:github.pypi.Quick StartFor easier use, commands should be called when git repository is your working directory. If you need to call outside working directory, you can use--repo-pathargument, where you specify for which repository it should be called.To know which commands are available, usegit trunk -hTo know what arguments are available and what they do for each command, usegit trunk <command> -horgit trunk <command> --helpRemote used is identified by your current branch tracking branch remote. If your current branch does not have tracking branch, then trunk branch tracking branch is checked. If trunk branch does not have tracking branch set, then it is assumed no remote is used forgit-trunkworkflow.SubmodulesAll possible commands can be used same way as on main superproject repository. Note configuration is still saved on main superproject repository config (submodules do not have git config file), but it is separated by including submodule relative path on sections. E.g. main repository section is named[trunk], where in submodule case, it is named[trunk "relpath/to/submodule"].initinitcommand is used to initialize git trunk configuration that is later reused for other commands. usually it is meant to be called once, where you specify options to set on configuration. Configuration is saved on your repository inside.git/configfile. Trunk sections are namedtrunk.When usinginitcommand, by default it runs in “interactive” mode, where you have to confirm default option values or enter new ones. If you want to specify all options without a prompt, use--no-confirmflag. With this flag, you can specify other argument and it will set without asking you to confirm it.If you need to change configuration, you can just callinitcommand again by specifying options you want to change. Options not specified, will be assumed that old values must be kept.startstartcommand is used to create new branch locally.Branch that is created, uses yourtrunkbranch as a fork.trunkbranch is always rebased from remotetrunkbefore creating new branch (if of course remote is used).When branch is created usingstartcommand, by default it will also try to set upstream for it. To not set upstream, use--no-set-upstreamflag when runningstartcommand.If you need to create new branch that is not already on remote, you can use--nameargument. It will simply try to create new branch (given it does not exist already) forking from your trunk branch.If you use system where branches are created on remote automatically (like tasks), you can configuregit-trunkto fetch specific branches only that are meant for you.startcommand will try to fetch the first one (naturally sorting branch names) from remotely existing branches you filtered. If remote branch is already used as tracking branch for existing local branch, such branch is ignored and not used in automatic branch creation.There are two ways to filter (can be combined):First one is by usingfetchbranchpatternoption. By default it fetches all available branches from your remote. To limit what is fetched, withinitcommand, for example you can set*-myvalue for argument--fetch-branch-pattern. With such pattern, it will only fetch branches which names end with-mypart. Pattern uses gitrefspec. Withinitcommand, you can changeasteriskpart, but skeleton remains the same:refs/heads/<pattern>:refs/remotes/<remote>/<pattern>Second can be specified every time you want to create new branch. For that you use--patternargument when callinggit trunk startcommand. Here you specifyregexpattern to further filter branches. This filtering option is used after fetched branches are filtered by refpsec pattern.finishfinishcommand is used to finish your temporary branch. In usual case, it is merged into trunk branch, pushed remotely and then remote respective branch is removed alongside local copy.Currently the only exception is if you use branch that hasreleaseprefix (initcommand argument is--release-branch-prefix). In this case such branch is recognized as release branch. When such branch is finished, it is only deleted, but not meged back into trunk. The reason is that release branches usually should not be merged into trunk.Branches by default will be merged with--ff-onlyflag. You can change to--no-ffflag withinitcommand.releasereleasecommand is used to create release tag.By default version is created using current latest commit on a branch you are on. But it is possible to use specific reference to tag on (with--refargument).Also release will be cancelled if there are no new changes after latest tag was created.Currently there are two possible ways to manage versions:Generic versioning. With generic, you need to manually specify new version every time. For that you use--versionargument, where you enter new version.Semver versioning, which uses pythonsemvermodule as a base to manage version bumping. By defaultminorpart is used, but with--partargument, you can specify other partssemvermodule currently supports.It is also possible to specify prefix for version. If prefix is used (it is set withinitcommand), custom version must be specified without prefix, so prefix would not be “duplicated”.Tag default message uses default template, where header line is version name and body is filled with abbreviated commits and their header lines being tagged. By default, tag message is opened for editing before being saved. Can be disabled if needed.refreshrefreshcommand is used to update your current branch with new changes from trunk. It can also be used on trunk branch itself.When you are on working branch, andrefreshcommand is called, your changes are stashed, then branch is changed to trunk, which then is rebased with its tracking branch (if it has upstream). Then branch is changed back to your working one, new trunk changes rebased on your working branch and stashed changes applied (if there were any).Some othergit-trunkcommands use refresh command internally to update code before executing command specific actions.If there are conflicts during refresh, command execution stops and conflicts must be resolved (if stashes were applied, dont forget to reapply them after solving conflicts).squashsquashcommand is used to squash multiple commits. Squash can’t be done on trunk branch.Before initiating squash itself, branch is refreshed with newest trunk branch changes, to make sure branch is up to date.By default it tries to squash all ahead trunk commits into first one. It is possible to specify how many commits to squash with--countargument. Value cant be greater than maximum possible commits to squash on that branch (or actually default count that is used).By default squash message generated is to concatenate all commit messages (including commit other commits are being squashed into). It is also possible to specify custom commit message, which replaces default message. It is also possible to not specify any message (but then edit mode must be enabled to enter one manually).By default squash message edit is enabled, which allows to edit tag message before it is saved. Can be disabled if needed.ContributorsAndrius Laukavičius (Focusate)