home/git: add git-fixup-fixup script

This commit is contained in:
Oystein Kristoffer Tveit 2024-11-13 16:32:36 +01:00
parent 61a22b96cd
commit 49f0a457e5
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
2 changed files with 20 additions and 0 deletions

View File

@ -53,6 +53,7 @@ in
forcepush = "push --force-with-lease --force-if-includes"; forcepush = "push --force-with-lease --force-if-includes";
authors = "shortlog --summary --numbered --email"; authors = "shortlog --summary --numbered --email";
si = "switch-interactive"; si = "switch-interactive";
ff = "fixup-fixup";
subs = "submodule update --init --recursive"; subs = "submodule update --init --recursive";
rebase-author = "rebase -i -x \"git commit --amend --reset-author -CHEAD\""; rebase-author = "rebase -i -x \"git commit --amend --reset-author -CHEAD\"";
git = "!git"; git = "!git";
@ -270,6 +271,11 @@ in
(builtins.replaceStrings ["hours" "tcommit"] ["minutes" "tmcommit"]) (builtins.replaceStrings ["hours" "tcommit"] ["minutes" "tmcommit"])
]; ];
}) })
(pkgs.writeShellApplication {
name = "git-fixup-fixup";
runtimeInputs = with pkgs; [ cfg.package ];
text = lib.fileContents ./scripts/git-fixup-fixup.sh;
})
(pkgs.writeShellApplication { (pkgs.writeShellApplication {
name = "git-switch-interactive"; name = "git-switch-interactive";
runtimeInputs = with pkgs; [ cfg.package fzf gnused coreutils ]; runtimeInputs = with pkgs; [ cfg.package fzf gnused coreutils ];

View File

@ -0,0 +1,14 @@
if [ -n "${1:-}" ]; then
TARGET_COMMIT="$1"
shift
else
TARGET_COMMIT="HEAD"
fi
COMMIT_MESSAGE=$(git log -1 --pretty=format:'%s' "$TARGET_COMMIT")
if [[ $COMMIT_MESSAGE =~ ^fixup!* ]]; then
git commit -m "$COMMIT_MESSAGE" "$@"
else
git commit --fixup "$TARGET_COMMIT" "$@"
fi