From c44a00fbcb7cde17f6662c6c95fb3c9d14637bcc Mon Sep 17 00:00:00 2001 From: Marcus Noble Date: Tue, 20 Jun 2023 08:50:31 +0100 Subject: [PATCH] Ensure git publish uses fork remote if found Signed-off-by: Marcus Noble --- home/.gitconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home/.gitconfig b/home/.gitconfig index c3fcacd..127473c 100644 --- a/home/.gitconfig +++ b/home/.gitconfig @@ -41,9 +41,9 @@ branch-name = "!git rev-parse --abbrev-ref HEAD" changelog-changed = "!test $(git diff --name-only HEAD origin/$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@') | grep CHANGELOG.md | wc -l | xargs) = 1" main-branch = "!git remote show origin|grep HEAD|sed 's/.* //'" - + fork-or-origin = "!func(){ $(git remote show fork &>/dev/null); if [[ $? == 0 ]]; then echo \"fork\" ; else echo \"origin\"; fi; }; func" main = "!git remote set-head origin --auto && git checkout $(git main-branch) && git pull" - publish = "!func(){ if [[ $(git branch-name) != \"$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')\" ]]; then git push -u origin $(git branch-name) && (git changelog-changed || echo '\n\n⚠️ Dont forget to update changelog ⚠️ ') ; else echo "Wat?!"; fi; }; func" + publish = "!func(){ if [[ $(git branch-name) != \"$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')\" ]]; then git push -u $(git fork-or-origin) $(git branch-name) && (git changelog-changed || echo '\n\n⚠️ Dont forget to update changelog ⚠️ ') ; else echo "Wat?!"; fi; }; func" cleanup = "!git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done" dont-change-file = "!git update-index --assume-unchanged" ignore-file = "!git update-index --skip-worktree"