Skip to main content

Git Gerrit Bridge

PyPI - Version PyPI - Python Version


Table of Contents

Motivation

Working with git and gerrit can be done in numerous ways, just to name a few:

  • No local branches and purely in detached HEAD mode
  • One local branch per remote branch
  • One local branch per bug/feature

Feature branches have the downside that there will be many and to keep the overview they have to be cleaned up/deleted regularly.

Git can do this for fully integrated branches with git branch -d <branch>. The issue is that often changes are purely modified in gerrit (rebase or online edits), preventing git from detecting if a local branch is fully integrated or not (git hashes differ).

The git gerrit script maps local changes to remote changes and can therefore handle such situations.
Let's look at an example usage.

Usage

  • Create a new local branch topic-1, tracking the remote origin/development branch:
    git gerrit new development topic-1
  • Do the implementation and commit:
    touch feature.txt
    git add feature.txt
    git commit -m "Added feature.txt"
  • Upload changes to gerrit (Commit chains are fine):
    The remote tracking branch is automatically used as target
    git gerrit push
  • Get an overview of your changes (remote and local):
    git gerrit status
┏━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
┃ Number  ┃ Subject                                       ┃   Status    ┃ Remote Branch  ┃ Local Branch ┃
┡━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━┩
│ 1000001 │ 🌐 Change only available in gerrit            │ Only Remote │ development    │              │
│ 1000003 │ 🌐 Change was edited or rebased in gerrit     │  Old Local  │ development    │ stale        │
│ 1000004 │ 🌐 Change was amended locally                 │ Old Remote  │ development    │ active       │
│ 1000009 │ 🌐 Added feature.txt                          │   In Sync   │ development    │ topic-1      │
│ 1000005 │ 🌐 Local and remote change have the same hash │   In Sync   │ feature-1      │ chain        │
│         │ ⚡ Local change not yet pushed to gerrit      │ Only Local  │ hot-fix        │ hacking      │
│ 1000006 │ 🐞 Follow up for 1000005 as commit chain      │   In Sync   │ feature-1      │ chain        │
│ 1000007 │ ❌ Change was merged in gerrit                │   Merged    │ development    │ bug123       │
│ 1000008 │ ❌ Change was abandoned in gerrit             │  Abandoned  │ development    │ bug321       │
└─────────┴───────────────────────────────────────────────┴─────────────┴────────────────┴──────────────┘
 🌐 Remote Change; ⚡ Local Change; 🐞 WIP Change; ❌ To be deleted; Click Number to open in browser
  • Remove fully integrated branches:
    git gerrit clean
Cleaning 8 branches:
branch_with_no_remote  ? Commits Skipped (no remote set)
active                 1 Commits Skipped (Not yet merged)
bug123                 1 Commits Deleted
bug321                 1 Commits Deleted
chain                  2 Commits Skipped (Not yet merged)
hacking                1 Commits Skipped (Not yet pushed)
stale                  1 Commits Skipped (Not yet merged)
topic-1                1 Commits Skipped (Not yet merged)

Further commands are:

  • git gerrit checkout <number> <branch>
    to download and checkout a gerrit change in a new local branch
  • git gerrit rebase
    to start an interactive rebase of the local changes without rebasing on the remote.
  • git gerrit sync
    to rebase the current branch by picking remote and local changes depending on which is newer.

Installation

pip install git-gerrit-bridge

License

git-gerrit is distributed under the terms of the GPL-3.0-or-later license.

Metadata

Release files for git-gerrit-bridge 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for git-gerrit-bridge 1.2.0
File Size Uploaded
git_gerrit_bridge-1.2.0.tar.gz 21.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for git-gerrit-bridge 1.2.0
File Interpreter ABI Platform
git_gerrit_bridge-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 50.0 kB

Release files / git_gerrit_bridge-1.2.0.tar.gz

Download URL git_gerrit_bridge-1.2.0.tar.gz
Size 21.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f1bd800464a0f26b37f4a46040b9d161b5076d53900b1eec4eac5c5b988846ea
BLAKE2b-256 checksum
How to use checksums
0b85929f912501fcdadc8e54eadd96b4cb6d336198a24054a92f2a45b15d9071
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / git_gerrit_bridge-1.2.0-py3-none-any.whl

Download URL git_gerrit_bridge-1.2.0-py3-none-any.whl
Size 28.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
263e7a7210906cf8f4c847b1fee0adb6b25fa51ca9c7b35bf4cedba8398295ba
BLAKE2b-256 checksum
How to use checksums
b64c95c32c8584f5cd8a82373b6ff9414ada001109e2f1fefa29db4a0b7d0fba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release 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