Skip to content

Commit

Permalink
Add git alias for Gitlab code reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
pkissling committed Oct 26, 2023
1 parent 717f2bd commit c86ea64
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions git/.gitconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions git/bin
Original file line number Diff line number Diff line change
Expand Up @@ -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/.* //')")"
}
5 changes: 3 additions & 2 deletions gpg/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ gpg --import ~/dotfiles/gpg/work.asc
# add private gpg key from 1password, if not exist
if [ -z "$(gpg --list-secret-keys)" ]; then
if [ "${USAGE}" = "work" ]; then
ONE_PASSWORD_DOCUMENT_ID="qoudpafw75h5i3lw7nyt67ewmq"
ONE_PASSWORD_VAULT="Azena"
else
ONE_PASSWORD_DOCUMENT_ID="n5zwvjshndohrik5k7jrjktfxe"
ONE_PASSWORD_VAULT="Personal"
fi
ONE_PASSWORD_DOCUMENT_ID=$(op item get 'GPG Private Key' --vault "${ONE_PASSWORD_VAULT}" --format json | jq -r .id)
gpg --import <(op document get "${ONE_PASSWORD_DOCUMENT_ID}")
fi
9 changes: 5 additions & 4 deletions ssh/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ ln -sfv "${HOME}"/.ssh/"${USAGE}".priv "${HOME}"/.ssh/id_rsa
ln -sfv "${HOME}"/dotfiles/ssh/config "${HOME}"/.ssh

# add private ssh key from 1password, if not exist
# shellcheck disable=SC2140
if [ ! -f "${HOME}"/.ssh/"${USAGE}.priv" ]; then
if [ "${USAGE}" = "work" ]; then
ONE_PASSWORD_VAULT="Azena"
ONE_PASSWORD_KEY_ID="2vgwjhx6xauti4mpxiltsalzyy"
else
ONE_PASSWORD_VAULT="Personal"
ONE_PASSWORD_KEY_ID="2uc6ialn2lqxqlpitlil4howha"
fi
op read op://"${ONE_PASSWORD_VAULT}"/"${ONE_PASSWORD_KEY_ID}"/'private key' > "${HOME}"/.ssh/"${USAGE}.priv"
chmod 600 ~/.ssh/id_rsa
ONE_PASSWORD_DOCUMENT_ID=$(op item get 'SSH Private Key' --vault "${ONE_PASSWORD_VAULT}" --format json | jq -r .id)
# shellcheck disable=SC2140
op read op://"${ONE_PASSWORD_VAULT}"/"${ONE_PASSWORD_DOCUMENT_ID}"/'private key' > "${HOME}"/.ssh/"${USAGE}.priv"
chmod 600 "${HOME}"/.ssh/"${USAGE}.priv"
fi

0 comments on commit c86ea64

Please sign in to comment.