From 83ea1cdd1fbd9c3ae7908ff1dd12363fee585b45 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Tue, 10 Oct 2023 13:31:58 -0400 Subject: Add git-branchless After using this for a while, I've decided that git-branchless will be the default tool for doing trunk-based development in the omnirepo. --- Biz/Bild.nix | 1 + Biz/Ide/hooks/post-applypatch.bash | 6 ++++++ Biz/Ide/hooks/post-checkout.bash | 4 ++++ Biz/Ide/hooks/post-commit.bash | 6 ++++++ Biz/Ide/hooks/post-merge.bash | 4 ++++ Biz/Ide/hooks/post-rewrite.bash | 6 ++++++ Biz/Ide/hooks/pre-auto-gc.bash | 6 ++++++ Biz/Ide/hooks/reference-transaction.bash | 12 ++++++++++++ 8 files changed, 45 insertions(+) create mode 100755 Biz/Ide/hooks/post-applypatch.bash create mode 100755 Biz/Ide/hooks/post-commit.bash create mode 100755 Biz/Ide/hooks/post-rewrite.bash create mode 100755 Biz/Ide/hooks/pre-auto-gc.bash create mode 100755 Biz/Ide/hooks/reference-transaction.bash diff --git a/Biz/Bild.nix b/Biz/Bild.nix index 409a0bc..4e1fb4c 100644 --- a/Biz/Bild.nix +++ b/Biz/Bild.nix @@ -139,6 +139,7 @@ in nixpkgs // { bild = rec { figlet fzf git + git-branchless gitlint jq lolcat diff --git a/Biz/Ide/hooks/post-applypatch.bash b/Biz/Ide/hooks/post-applypatch.bash new file mode 100755 index 0000000..5071dc5 --- /dev/null +++ b/Biz/Ide/hooks/post-applypatch.bash @@ -0,0 +1,6 @@ +#!/bin/sh +## START BRANCHLESS CONFIG + +git branchless hook post-applypatch "$@" + +## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/post-checkout.bash b/Biz/Ide/hooks/post-checkout.bash index 73488b0..982cb4b 100755 --- a/Biz/Ide/hooks/post-checkout.bash +++ b/Biz/Ide/hooks/post-checkout.bash @@ -13,3 +13,7 @@ then $mktags $changed fi direnv reload +## START BRANCHLESS CONFIG + +git branchless hook post-checkout "$@" +## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/post-commit.bash b/Biz/Ide/hooks/post-commit.bash new file mode 100755 index 0000000..cd1f195 --- /dev/null +++ b/Biz/Ide/hooks/post-commit.bash @@ -0,0 +1,6 @@ +#!/bin/sh +## START BRANCHLESS CONFIG + +git branchless hook post-commit "$@" + +## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/post-merge.bash b/Biz/Ide/hooks/post-merge.bash index c21211f..94f0f60 100755 --- a/Biz/Ide/hooks/post-merge.bash +++ b/Biz/Ide/hooks/post-merge.bash @@ -1,2 +1,6 @@ #!/usr/bin/env bash exec ${CODEROOT:?}/Biz/Ide/hooks/post-checkout 'HEAD@{1}' HEAD +## START BRANCHLESS CONFIG + +git branchless hook post-merge "$@" +## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/post-rewrite.bash b/Biz/Ide/hooks/post-rewrite.bash new file mode 100755 index 0000000..8b3237a --- /dev/null +++ b/Biz/Ide/hooks/post-rewrite.bash @@ -0,0 +1,6 @@ +#!/bin/sh +## START BRANCHLESS CONFIG + +git branchless hook post-rewrite "$@" + +## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/pre-auto-gc.bash b/Biz/Ide/hooks/pre-auto-gc.bash new file mode 100755 index 0000000..c92a844 --- /dev/null +++ b/Biz/Ide/hooks/pre-auto-gc.bash @@ -0,0 +1,6 @@ +#!/bin/sh +## START BRANCHLESS CONFIG + +git branchless hook pre-auto-gc "$@" + +## END BRANCHLESS CONFIG diff --git a/Biz/Ide/hooks/reference-transaction.bash b/Biz/Ide/hooks/reference-transaction.bash new file mode 100755 index 0000000..ea0cce6 --- /dev/null +++ b/Biz/Ide/hooks/reference-transaction.bash @@ -0,0 +1,12 @@ +#!/bin/sh +## START BRANCHLESS CONFIG + +# Avoid canceling the reference transaction in the case that `branchless` fails +# for whatever reason. +git branchless hook reference-transaction "$@" || ( +echo 'branchless: Failed to process reference transaction!' +echo 'branchless: Some events (e.g. branch updates) may have been lost.' +echo 'branchless: This is a bug. Please report it.' +) + +## END BRANCHLESS CONFIG -- cgit v1.2.3