From 4fa05913c30a47544de0ee1a70a9054594f75e29 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 15 Jun 2016 22:24:10 -0700 Subject: [PATCH 1/2] Script to init the upstream remote for Marlin --- buildroot/share/git/mfinit | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100755 buildroot/share/git/mfinit diff --git a/buildroot/share/git/mfinit b/buildroot/share/git/mfinit new file mode 100755 index 000000000..5e2cbc0d8 --- /dev/null +++ b/buildroot/share/git/mfinit @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# +# mfinit +# +# Create the upstream repository for Marlin +# + +git remote add upstream git@github.com:MarlinFirmware/Marlin.git From 340f97d6357b752143a352b243592aaa3662cf4a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 16 Jun 2016 12:56:39 -0700 Subject: [PATCH 2/2] Add ghtp script to set remotes to HTTP or SSL --- buildroot/share/git/ghtp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 buildroot/share/git/ghtp diff --git a/buildroot/share/git/ghtp b/buildroot/share/git/ghtp new file mode 100755 index 000000000..83f461ef1 --- /dev/null +++ b/buildroot/share/git/ghtp @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# +# ghtp (GitHub Transport Protocol) +# +# Set all remotes in the current repo to HTTPS or SSH connection. +# Useful when switching environments, using public wifi, etc. +# + +GH_SSH="git@github\.com:" +GH_HTTPS="https:\/\/github\.com\/" + +case "$1" in + -[Hh]) TYPE=HTTPS ; MATCH="git@" ; FORMULA="$GH_SSH/$GH_HTTPS" ;; + -[Ss]) TYPE=SSH ; MATCH="https:" ; FORMULA="$GH_HTTPS/$GH_SSH" ;; + *) + echo "Usage: `basename $0` -h | -s" 1>&2 + echo -e " \e[0;92m-h\e[0m to switch to HTTPS" 1>&2 + echo -e " \e[0;92m-s\e[0m to switch to SSH" 1>&2 + exit 1 + ;; +esac + +REMOTES=$(git remote -v | egrep "\t$MATCH" | gawk '{print $1 " " $2}' | sort -u | sed "s/$FORMULA/") + +if [[ -z $REMOTES ]]; then + echo "Nothing to do." ; exit +fi + +echo "$REMOTES" | xargs -n2 git remote set-url + +echo -n "Remotes set to $TYPE: " +echo "$REMOTES" | gawk '{printf "%s ", $1}' +echo