This release is a pre-release and may not be stable for production use.
git-mr-linear
A command line utility to list and merge GitLab 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-mr-linear
To upgrade to the latest version:
pip3 install --upgrade git-mr-linear
How To Use
Get help: git mr -h
The first time you run this script, you will be asked to authenticate with Gitlab.
List Command
List all open pull requests: git mr list, or list only yours with git mr 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 mr merge NUMBER
Squash Command
Squash a pull request: git mr 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 mr squash` command
squash_cmd_enabled = True
Troubleshooting
- You see "git: mr is not a git command"
- Run
sudo pip3 install git-mr-linearand see if you receive a yellow warning message indicating..../Library/Caches/pipis not writable by the current user. This indicates the installation has not completed successfully due to incorrect write permissions - Run
sudo -H pip3 install git-mr-linear - If the error still persists, make sure you have write access to
~/Library/Python/3.X/bin. Runsudo -H pip3 install git-mr-linearagain if you changed any write permissions
- Run
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 mr using your local code by running the git-mr.py script in the root directory of this repo.
python3 ~/path/to/your/local/checkout/git-mr.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-mr-linear
Publish
source venv/bin/activate
rm -rf dist
rm -rf build
python -m build
twine upload dist/*
Release files for git-mr-linear 0.0.6a0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| git-mr-linear-0.0.6a0.tar.gz | 12.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| git_mr_linear-0.0.6a0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.7 kB
Release files / git-mr-linear-0.0.6a0.tar.gz
| Download URL | git-mr-linear-0.0.6a0.tar.gz |
|---|---|
| Size | 12.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c2003ac4a396283fef0456d335a37962b6f5a230b9936ebe3c4612e5b82ed68
|
|
BLAKE2b-256 checksum How to use checksums |
ca919f01a48331015f91d8c20e19eb1c3ff1aa5371c18298a56dc8f33bdbad39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.10.4
|
Release files / git_mr_linear-0.0.6a0-py3-none-any.whl
| Download URL | git_mr_linear-0.0.6a0-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
44ffb2896fa90c8fe1c644050f6b7b19460b1c2c7d158d6598398a24d6e70c39
|
|
BLAKE2b-256 checksum How to use checksums |
486f9dbaf5fdacc8d5124fa6b4230e2d442952c8c97b5a5f55c5c7064d2e0eef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.10.4
|