home/git: add fixup-interactive script
This commit is contained in:
parent
35e75ec9ad
commit
e0a957e448
|
@ -52,6 +52,7 @@ in
|
|||
authors = "shortlog --summary --numbered --email";
|
||||
si = "switch-interactive";
|
||||
ff = "fixup-fixup";
|
||||
fi = "fixup-interactive";
|
||||
rf = "rebase-fixups";
|
||||
pp = "post-pr";
|
||||
subs = "submodule update --init --recursive";
|
||||
|
@ -335,6 +336,11 @@ in
|
|||
runtimeInputs = with pkgs; [ cfg.package gnused ];
|
||||
text = lib.fileContents ./scripts/git-rebase-fixups.sh;
|
||||
})
|
||||
(pkgs.writeShellApplication {
|
||||
name = "git-fixup-interactive";
|
||||
runtimeInputs = with pkgs; [ cfg.package gnused gnugrep fzf ];
|
||||
text = lib.fileContents ./scripts/git-fixup-interactive.sh;
|
||||
})
|
||||
(pkgs.writeShellApplication {
|
||||
name = "git-switch-interactive";
|
||||
runtimeInputs = with pkgs; [ cfg.package fzf gnused coreutils ];
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
if [ -n "${1:-}" ]; then
|
||||
TARGET_BRANCH="$1"
|
||||
shift
|
||||
else
|
||||
TARGET_BRANCH=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')
|
||||
fi
|
||||
|
||||
FORK_POINT=$(git merge-base --fork-point "$TARGET_BRANCH")
|
||||
|
||||
COMMITS_SINCE_FORK_POINT=$(git log --format=format:'%s' "$FORK_POINT"..HEAD | grep -v -E '^fixup!')
|
||||
|
||||
RESULT=$(fzf <<<"$COMMITS_SINCE_FORK_POINT")
|
||||
|
||||
if [ "$RESULT" == "" ]; then
|
||||
echo "Doing nothing..."
|
||||
else
|
||||
git commit -m "fixup! $RESULT" "$@"
|
||||
fi
|
Loading…
Reference in New Issue