From 79bea1364a2a1040ea7127752aef1e16e7009e4e Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Wed, 5 Jun 2024 20:18:01 +0200 Subject: [PATCH] bash: move gc to scripts Signed-off-by: Michael Grote --- .bash_functions | 30 ------------------------------ scripts/gc | 1 + scripts/git_checkout | 28 ++++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 30 deletions(-) create mode 120000 scripts/gc create mode 100755 scripts/git_checkout diff --git a/.bash_functions b/.bash_functions index bcf660d..8b9dde8 100644 --- a/.bash_functions +++ b/.bash_functions @@ -57,36 +57,6 @@ function gcm { git commit -s -m "$*" fi } -function gc { - case "$1" in - --help | -h) - cat <>> Create new branch "'"$2"'"') || (git checkout --quiet "$2" > /dev/null 2>&1 && echo '>>> Branch already exists, checking out... ') - ;; - *) - if [ -n "$1" ] ; then - (echo ">>> Try local checkout" && git checkout --quiet "$1" > /dev/null 2>&1) || (echo ">>> Try remote checkout" && git checkout --quiet -b "$1" origin/"$1" > /dev/null 2>&1 || echo ">>> Unkown branch!") - else - (git checkout --quiet master > /dev/null 2>&1 && echo '>>> Try checking out master') || (git checkout --quiet main > /dev/null 2>&1 && echo '>>> Try checking out main') || (git checkout --quiet release > /dev/null 2>&1 && echo '>>> Try checking out release') - fi - esac -} function gp { git pull "$@" } diff --git a/scripts/gc b/scripts/gc new file mode 120000 index 0000000..fc8f2aa --- /dev/null +++ b/scripts/gc @@ -0,0 +1 @@ +git_checkout \ No newline at end of file diff --git a/scripts/git_checkout b/scripts/git_checkout new file mode 100755 index 0000000..cd854be --- /dev/null +++ b/scripts/git_checkout @@ -0,0 +1,28 @@ +#!/bin/bash +case "$1" in +--help | -h) + cat <>> Create new branch "'"$2"'"') || (git checkout --quiet "$2" > /dev/null 2>&1 && echo '>>> Branch already exists, checking out... ') + ;; +*) + if [ -n "$1" ] ; then (echo ">>> Try local checkout" && git checkout --quiet "$1" > /dev/null 2>&1) || (echo ">>> Try remote checkout" && git checkout --quiet -b "$1" origin/"$1" > /dev/null 2>&1 || echo ">>> Unkown branch! ") + else + (git checkout --quiet master > /dev/null 2>&1 && echo '>>> Try checking out master') || (git checkout --quiet main > /dev/null 2>&1 && echo '>>> Try checking out main') || (git checkout --quiet release > /dev/null 2>&1 && echo '>>> Try checking out release') + fi +esac