A command line utility to list and merge GitHub pull requests while maintaining linear history
Project description
git-pr-linear-merge
A command line utility to list and merge GitHub pull requests while maintaining linear history.
To maintain linear history, a pull request branch is rebased on top of its base, before merging. This creates a linear history like in this diagram:
Further Reading & Context
- A Tidy Linear Git History
- Avoid Messy Git History
- A Git Workflow for Agile Teams
- Git Rebase Tutorial
Usage
Installing
Python3.6 or above is required. You can install this package by running the following command:
pip3 install git-pr-linear-merge
To upgrade to the latest version:
pip3 install --upgrade git-pr-linear-merge
How To Use
Get help: git pr -h
The first time you run this script, you will be asked to authenticate with Github.
List Command
List all open pull requests: git pr list
, or list only yours with git pr list --mine
# Title Branch
---- ------------------------------------------------------------ -------------------------------
5811 Fix various bugs with video player fix/kevin-video-player-bugs
5812 Fix highlight being stuck when gallery frame is deactivated fix/kevin-highlightable-view
...
Merge Command
Merge a pull request: git pr merge NUMBER
Squash Command
Squash a pull request: git pr squash NUMBER
The squash command collapses all commits from the pull branch into a single commit and puts that commit straight onto the base branch without doing an explicit merge.
Here's what the history looks like when you use squash
vs merge
.
Repo configuration
Add a .linmergerc
config file to the repo root directory to customize behaviour to your teams preference.
Below are all the options
[merge]
# Commit message format vars: TITLE, NUMBER, AUTHOR_NAME, AUTHOR_USERNAME
merge_msg_format = Merge: {TITLE} (#{NUMBER})
# Enable single-commit pulls to be squashed instead of merging, even when explicitly using the merge command
always_squash_single_commit_pulls = True
[squash]
squash_msg_format = {TITLE} (#{NUMBER})
# Enable usage of the `git pr squash` command
squash_cmd_enabled = True
Development
This section explains how to setup the dev environment and update the package
Environment setup
python3 -m pip install virtualenv
python3 virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
Running Locally
With the environment setup through the previous step, you can run git pr
using your local code by running the git-pr.py
script in the root directory of this repo.
python3 ~/path/to/your/local/checkout/git-pr.py
Updating the package
Make sure to bump the version number with updates according to PEP 440
Publish and Install from TestPyPi
Before publishing for real, you can test a package by publishing it to TestPyPi
Publishing:
source venv/bin/activate
rm -rf dist
rm -rf build
python -m build
twine upload --repository testpypi dist/*
Installing:
python3 -m pip install --index-url https://test.pypi.org/simple/ git-pr-linear-merge
Publish
source venv/bin/activate
rm -rf dist
rm -rf build
python -m build
twine upload dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for git-pr-linear-merge-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1feb6a5e3d51d5ed5411a72439130b7f5d65212283a2f381a3842dead55fc657 |
|
MD5 | 1116ae75e3511c6531092a96aecd78f5 |
|
BLAKE2b-256 | 365bffa740f0aa26a78f7cc28e4362b91152a9273def94f3498474a42d64e862 |
Hashes for git_pr_linear_merge-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5da6e6469136fdcf581ca5a05a694e515a3133c9d8b8b323163187b848bd3ad8 |
|
MD5 | 1ffc23ee8dc3815705cbebde2817d5c3 |
|
BLAKE2b-256 | 8b12c309ba6651e364e1196dd0102e75a8b2f0a576cd77f0d1ab631ee6116e97 |