diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2024-01-15 16:23:40 +0100 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2024-03-01 00:22:54 +0100 |
commit | d9ff223bbdab213a35ab59031d258a3635b86c2f (patch) | |
tree | 5f20a9c3ea7a2cbb150c29686feb2b03e10baad6 /git-request-get | |
parent | a681a34749cd3e79f0db9a56b4e5172d84f42e74 (diff) | |
download | hlupak-d9ff223bbdab213a35ab59031d258a3635b86c2f.tar.gz |
feat(git-request-get): Simplicity, plain /bin/sh, don’t do anything you needn’t to do.
Diffstat (limited to 'git-request-get')
-rwxr-xr-x | git-request-get | 29 |
1 files changed, 2 insertions, 27 deletions
diff --git a/git-request-get b/git-request-get index c85b681..ad89ae3 100755 --- a/git-request-get +++ b/git-request-get @@ -1,39 +1,14 @@ -#!/bin/bash +#!/bin/sh set -eu -if [ $# -lt 1 ] ; then STR="$(cat)" -else -echo "No options yet!" -exit 1 -fi -# 1. Collect URL of the incoming repo URL="$(echo "$STR" | sed -n -e '/^are available in the Git repository at:/,+2 { s/[[:space:]]\+// s/\(=[[:digit:]]\{2\}\)\+$// /^\(http\|git\)/p }')" -# 2. Check it is in our remotes -mapfile REMOTES < <(git remote -v|awk '{print $1,$2;}') -REMOTE='' -for rem in "${REMOTES[@]}" ; do - if [[ ${rem} =~ $URL ]] ; then - REMOTE="$(echo "${rem}" | awk -F ' ' '{print $1;}' )" - break - fi -done - -# 3. Find the tip of the offered branch END="$(echo "$STR" | awk '/^for you to fetch changes up to / { print $NF }' | sed -e 's/[=:]*$//')" - -# 4. Fetch the remote -if [[ -n "$REMOTE" ]] ; then - git fetch "$REMOTE" "$END" -else - git fetch "$URL" "$END" -fi - -# 5. open new branch +git fetch "$URL" "$END" git checkout -B _4review FETCH_HEAD |