Git dibs
Claim a git commit id so that other developers know not to use it. Reciprocate by not using theirs.
Call dibs on a commit id
No longer do you need to send an email to everyone in your company or post a heads-up on LinkedIn that you're reserving a sha-1 hash for future use.
Now it's as easy as git dibs.
dev@crudco:~/crud-app$
Never again accidentally steal another developer's dibs
Install our post-commit hook in your repo to roll back any attempt to violate another developer's trust and goodwill. Tell your teammates they're lucky the reset is --soft, and you won't be so generous next time.
dev@crudco:~/crud-app$
Check for dibs
If you don't want a post-commit hook calling you a cotton-headed ninnymuggins for trying to steal an innocent developer's commit id, you can preemptively check for called-dibs with the following git alias. You don't want to commit a war crime, do you?
dev@crudco:~/crud-app$
Post-Commit Hook Installation
You're not actually considering doing this, are you?
- Install
pre-commit,colorama, andgit-dibs-sdkwithpython -m pip install pre-commit colorama git-dibs-sdk. - Put
git-dibs-checker.pyin the root of your repository. - Create a
.pre-commit-config.yamlfile like the one below. The sample usesuv; if you are not using it, change the entry topython ./git-dibs-checker.py. - Run
python -m pre_commit install --hook-type post-commitoruv run pre-commit install --hook-type post-commitso Git actually installs thepost-commithook.
git-dibs-checker.py
#!/usr/bin/env python3
import subprocess
import sys
from colorama import just_fix_windows_console, Fore
just_fix_windows_console()
from git_dibs_sdk import GitDibsClient
def recent_commit() -> str | None:
result = subprocess.run(
["git", "log", "-1", "--pretty=format:%H", "HEAD"],
check=True,
capture_output=True,
text=True,
)
return result.stdout.strip() or None
def soft_reset(commit_id: str) -> None:
subprocess.run(
["git", "reset", "--soft", f"{commit_id}~1"],
check=True,
capture_output=True,
text=True,
)
print(f"{Fore.YELLOW}Soft reset {commit_id}{Fore.RESET}", file=sys.stderr)
client = GitDibsClient("https://gitdibs.com")
commit_id = recent_commit()
if commit_id is None:
sys.exit(0)
dibs = client.get_dibs(commit_id)
if dibs is not None:
print(
f"{Fore.RED}Sorry, {dibs.reserved_by} already called dibs on commit {commit_id}. Please pad a random file with whitespace and try again.{Fore.RESET}",
file=sys.stderr,
)
soft_reset(commit_id)
.pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: git-dibs-checker
name: git dibs check
language: unsupported
entry: uv run python ./git-dibs-checker.py
stages: [post-commit]
always_run: true
pass_filenames: false
files: ^$
repos:
- repo: local
hooks:
- id: git-dibs-checker
name: git dibs check
language: unsupported
entry: uv run python ./git-dibs-checker.py
stages: [post-commit]
always_run: true
pass_filenames: false
files: ^$
Git Alias Installation
Seriously, stop. Alright, fine. Here is how to create git dibs and git dibs-check git aliases.
- Install
coloramaandgit-dibs-sdkwithpython -m pip install colorama git-dibs-sdk. - Copy
git-dibs.pyandgit-dibs-check.pyinto your repository root. - Open your repository
.git/configor your global~/.gitconfig. - Add the
[alias]block from the sample.gitconfigbelow. - Run
git dibs <40-char-commit-id> <AlphanumericName>, for examplegit dibs deadbeefdeadbeefdeadbeefdeadbeefdeadbeef SamFromLondon. - Run
git dibs-check <40-char-commit-id>to see whether a commit is already taken and by whom.
git-dibs.py
#!/usr/bin/env python3
import sys
from colorama import Fore, just_fix_windows_console
just_fix_windows_console()
from git_dibs_sdk import (
DibsAlreadyCalledError,
GitDibsClient,
GitDibsError,
)
client = GitDibsClient("https://gitdibs.com")
commit_id = sys.argv[1].strip().lower()
reserved_by = sys.argv[2].strip()
try:
dibs = client.call_dibs(commit_id, reserved_by)
except DibsAlreadyCalledError as error:
owner = error.reserved_by or "someone else"
print(f"{Fore.RED}Sorry, {error.commit_hash} is already reserved by {owner}.{Fore.RESET}", file=sys.stderr)
raise SystemExit(1)
except GitDibsError as error:
print(f"{Fore.RED}{error}{Fore.RESET}", file=sys.stderr)
raise SystemExit(1)
print(f"{Fore.GREEN}Successfully reserved {dibs.hash}{Fore.RESET}")
git-dibs-check.py
#!/usr/bin/env python3
import sys
from git_dibs_sdk import GitDibsClient, GitDibsError
client = GitDibsClient("https://gitdibs.com")
commit_id = sys.argv[1].strip().lower()
try:
dibs = client.get_dibs(commit_id)
except GitDibsError as error:
print(error, file=sys.stderr)
raise SystemExit(1)
if dibs is None:
print(f"{commit_id} is available!")
else:
print(f"{dibs.hash} is reserved by {dibs.reserved_by}")
.gitconfig
[alias]
dibs = "!f() { python ./git-dibs.py \"$@\"; }; f"
dibs-check = "!f() { python ./git-dibs-check.py \"$@\"; }; f"
[alias]
dibs = "!f() { python ./git-dibs.py \"$@\"; }; f"
dibs-check = "!f() { python ./git-dibs-check.py \"$@\"; }; f"
Call dibs on a commit
If you're "not a command line person", that's okay. Just copy-paste your desired commit id in the form below and hit "Dibs!"
Search for reserved commit ids
Check to see of a hash is reserved, or just look up your personal favorite.
Search Results
Matching reserved commits for your current query.
| Upvotes | Commit | Name | Reserved |
|---|
10 Most Recent Reserved Commits
Get yours before they run out. Only 1.4615016e+48 left!
| Upvotes | Commit | Name | Reserved |
|---|
10 Most Popular Commits
Don't forget to vote on your favorite. Your vote matters!
| Upvotes | Commit | Name | Reserved |
|---|
Frequently asked question
Why?