From 6bad26d12b42e78cd1ad9443be4fe80a0ed1207a Mon Sep 17 00:00:00 2001 From: Patrick Kissling Date: Thu, 26 Oct 2023 16:16:41 +0200 Subject: [PATCH] Add git alias for Gitlab code reviews --- git/.gitconfig | 1 + git/bin | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/git/.gitconfig b/git/.gitconfig index 6ce43f5..7d596f4 100644 --- a/git/.gitconfig +++ b/git/.gitconfig @@ -47,6 +47,7 @@ fuzzy-checkout-ticket = !bash -c 'source $HOME/.git/bin && git-fuzzy-checkout-ticket' fuzzy-rebase = !bash -c 'source $HOME/.git/bin && git-fuzzy-rebase' fuzzy-diff = !bash -c 'source $HOME/.git/bin && git-fuzzy-diff' + gitlab-review = !bash -c 'source $HOME/.git/bin && git-gitlab-code-review \"$1\"' [core] pager = delta --dark diff --git a/git/bin b/git/bin index 84630ae..b98e7ca 100755 --- a/git/bin +++ b/git/bin @@ -56,3 +56,9 @@ git-fuzzy-checkout-ticket() { git cob dev/"${ticket_id}"_"${slug}" git psu } + +git-gitlab-code-review() { + git fetch origin refs/merge-requests/"${0}"/head + git switch --detach FETCH_HEAD + git reset $(git merge-base HEAD $(git remote show origin | grep HEAD | sed 's/.* //')) +}