Skip to main content

Overview

This package contains command line tools to streamline common tasks in our git workflow.

Start New Branch with Commit Template

To start a new branch, run:

workflow start

This will prompt you for some information and create a new branch with the following name format:

[<client>-]<brief-description>-<yyyymmdd>-<initials>

If you provide a ticket number, this will create a git commit message template for the branch. By default, the commit template will be in the following format:

[<ticket#>]

Create a Commit Template for an Existing Branch

If you already have a branch created and would like to create a commit template, run:

workflow set-template

Remove a Branch’s Commit Template

To remove a branch’s commit template without deleting the branch, run:

workflow unset-template

Setup

Prerequisites

Python 3.6+

This package was developed using features that require Python 3.6 or greater (developed using Python 3.9.2).

You can use this guide to install Python 3 on macOS.

Git 2.23+

This package uses features that require Git 2.23 or greater.

To install an updated version of git on macOS using Homebrew:

brew install git

Note: Make sure /usr/local/bin is added to your PATH. You can do this by adding the following to your .bashrc:

export PATH="/usr/local/bin:$PATH"

Installation

Once you have the above prerequisites installed, you can install it using pip (or pip3 depending on how you installed Python 3):

pip install git-workflow

Configure Git to Ignore Commit Template Files

These commands generate files for commit templates, which you likely do not want to track in your repos.

Ignore for a Single Repo

To ignore generated template files in a single git repo, add the following to the .gitignore file:

# Commit message templates
.gitmessage_local*

Workflow Commands

Usage: workflow <command>

start

Create a new branch with the following name format:

[<client>-]<brief-description>-<yyyymmdd>-<initials>

Where:

  • <client> - (Optional) Client’s name

  • <brief-description> - Description of the work

  • <yyyymmdd> - Today’s date

  • <initials> - Engineer’s initials

Script will prompt for details and format appropriately (i.e. no spaces/underscores, all lowercase).

Usage

usage: workflow start [-h] [-V] [-c <client> | -C] [-d <description>] [-i <initials>] [-s] [-t <ticket#> | -T] [-b <branch> | -B | -P]

Create a new branch.

General:
  -h, --help            Show this help message and exit
  -V, --version         Show version number and exit

Branch Name Arguments:
  -c <client>, --client <client>
                        Specify client name
  -C, --no-client       No client name (skips prompt)
  -d <description>, --description <description>
                        Specify branch description
  -i <initials>, --initials <initials>
                        Specify developer initials
  -s, --skip-bad-name-check
                        Skip check for bad branch names

Commit Template Arguments:
  -t <ticket#>, --ticket <ticket#>
                        Specify ticket number (will create commit template)
  -T, --no-ticket       Skip ticket number prompt, don't create commit template (overrides -t)

Branching Arguments:
  -b <branch>, --base-branch <branch>
                        Specify branch to use as base for new branch (default: master)
  -B, --branch-from-current
                        Use currently checked out branch as base (overrides -b)
  -P, --no-pull         Skip pulling changes to base branch.

Configs

Command uses the following configs:

set-template

Create and configure commit template for the current branch.

By default, the commit template includes the specified ticket number before the commit message. E.g. for ticket number AB-12345:

[AB-12345] <commit message text starts here>

The commit template file will be created in the root of the git repository. By default, the filename will be in this format:

.gitmessage_local_<ticket>_<branch>

The format of the filename, commit template body, accepted ticket numbers, and more can be customized with git configs (see the Configs section below for details).

Usage

usage: workflow set-template [-h] [-V] [<ticket>]

Configure git commit template for a branch.

General:
  -h, --help     Show this help message and exit
  -V, --version  Show version number and exit

Positional Arguments:
  <ticket>       Ticket number to use in commit template

Configs

Command uses the following configs:

unset-template

Remove commmit template for a branch.

By default, this command will prompt for confirmation before removing the commit template unless --force is specified.

Usage

usage: workflow unset-template [-h] [-V] [-f | -c] [<branch>]

Remove commit template for a branch.

General:
  -h, --help          Show this help message and exit
  -V, --version       Show version number and exit

Positional Arguments:
  <branch>            Branch to unset template for (default: current)

Confirmation Prompt Arguments:
  Override workflow.unsetTemplateConfirmationPrompt config.

  -f, --force         Skip confirmation prompt (if configured)
  -c, --confirmation  Prompt for confirmation before unsetting

Configs

Command uses the following configs:

Git Configurations

Workflow commands will use the following git configs if set:

User Details

workflow.initials

The user’s initials.

If set, workflow start will skip the prompt for your initials and use this value.

E.g.: To set your initials to “cd”:

git config --global workflow.initials cd

Branches

workflow.baseBranch

Default: master

Branch to use as a base when creating a new branch using workflow start.

E.g.: To base branches off of develop:

git config workflow.baseBranch develop

workflow.badBranchNamePatterns

Set to a space-separated string of phrases or patterns that should not appear in a standard branch name. If set, workflow start will check for these before attempting to create a new branch.

E.g.: if standard branch names shouldn’t include the words -web or -plugins:

git config workflow.badBranchNamePatterns "-web -plugins"

Commit Templates

workflow.commitTemplateFormat

Default: '[{ticket}] '

Format of commit template body. Supports the following placeholders:

  • {ticket}: Replaced with ticket number

  • {branch}: Replaced with branch name

  • {initials}: Replaced with user initials (if configured)

workflow.commitTemplateFilenameFormat

Default: '{ticket}_{branch}'

Format of commit template filenames. Supports same placeholders as workflow.commitTemplateFormat.

NOTE: Resulting filenames will always begin with '.gitmessage_local_'.

workflow.unsetTemplateConfirmationPrompt

Default: true

If true, workflow unset-template will prompt for confirmation before unsetting unless -f is specified. If false, will not prompt for confirmation unless -i is specified.

Ticket Numbers

workflow.ticketInputFormatRegex

Default: '[a-zA-Z]+-[0-9]+'

Regex representing the format of a valid ticket number. Default format is 1 or more letters, then a hyphen, then 1 or more numbers. To allow any format, set to '.*'.

workflow.ticketFormatCapitalize

Default: true

If true, letters in the ticket number will be capitalized after validation.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git_workflow-0.1.0.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_workflow-0.1.0-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file git_workflow-0.1.0.tar.gz.

File metadata

  • Download URL: git_workflow-0.1.0.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for git_workflow-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5289509eb52580e87d127e1074867336df36b8ed3642c28ec9e1e4ad953722af
MD5 0732d54bb19763d68cff729eb411c460
BLAKE2b-256 ddba85fc568d7a4d47b39e745831c35126c38b99b47493db6284deaffedb557b

See more details on using hashes here.

File details

Details for the file git_workflow-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: git_workflow-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for git_workflow-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93498b98cdbfbd941a2d8a5e02aef67e2598fc8fc2ff4a039dd9de964186b637
MD5 f2e32950e810566a08e1699f6e6d9a9a
BLAKE2b-256 c968037ba810031b0fee830fefea327c67fe67231b83a29cfae5b317c8b91641

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page