home

My NixOS systems configurations.
Log | Files | Refs | LICENSE

lib.mr (1414B)


      1 # -*- mode: sh -*-
      2 [DEFAULT]
      3 lib =
      4     my_git_clone() {
      5         USERNAME=${GIT_USERNAME:-git}
      6         GIT_PREFIX=${GIT_PREFIX}
      7         GIT_BASE=${GIT_BASE:-${BASE_HOST}}
      8         URL="${GIT_PREFIX}${USERNAME}@${GIT_BASE}${MR_REPO//$(dirname ${MR_CONFIG})}.git"
      9         UPSTREAM_URL=""
     10         if [[ -z "$NO_UPSTREAM_U" ]]; then
     11             URL="${GIT_PREFIX}${USERNAME}@${GIT_BASE}:${BASE_USER}/${BASE_PATH}-${MR_REPO//$(dirname ${MR_CONFIG})\/}.git"
     12             UPSTREAM_URL="https://${GIT_BASE}/${BASE_PATH}${MR_REPO//$(dirname ${MR_CONFIG}\/)}.git"
     13         fi
     14         echo "URL         : $URL"
     15         echo "UPSTREAM_URL: $UPSTREAM_URL"
     16         git clone $URL $MR_REPO
     17         if [[ -n "$UPSTREAM_URL" ]]; then
     18             cd $MR_REPO
     19             git remote add upstream $UPSTREAM_URL
     20             git fetch -p --all
     21         fi
     22     }
     23 checkout = my_git_clone
     24 git_gc = git gc "$@"
     25 # git_u = git pull --rebase --autostash "$@"
     26 git_u =
     27     git fetch -p --all
     28     CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
     29     DEFAULT_BRANCH=${DEFAULT_BRANCH:-main}
     30     echo "On $CURRENT_BRANCH"
     31     git stash
     32     REMOTE="origin"
     33     if [[ -z "$NO_UPSTREAM_U" ]]; then
     34         git config remote.upstream.url && REMOTE="upstream"
     35     fi
     36     echo "Rebase ${REMOTE}/${DEFAULT_BRANCH} on ${DEFAULT_BRANCH}"
     37     git rebase ${REMOTE}/${DEFAULT_BRANCH} ${DEFAULT_BRANCH}
     38     git co $CURRENT_BRANCH
     39 skip = [ $1 != "checkout" ] && lazy