Browse Source

Merge pull request #4056 from thinkyhead/rc_mfinit

Script to init the upstream remote for Marlin
Scott Lahteine 8 years ago
parent
commit
9030ceec1d
2 changed files with 41 additions and 0 deletions
  1. 33
    0
      buildroot/share/git/ghtp
  2. 8
    0
      buildroot/share/git/mfinit

+ 33
- 0
buildroot/share/git/ghtp View File

@@ -0,0 +1,33 @@
1
+#!/usr/bin/env bash
2
+#
3
+# ghtp (GitHub Transport Protocol)
4
+#
5
+# Set all remotes in the current repo to HTTPS or SSH connection.
6
+# Useful when switching environments, using public wifi, etc.
7
+#
8
+
9
+GH_SSH="git@github\.com:"
10
+GH_HTTPS="https:\/\/github\.com\/"
11
+
12
+case "$1" in
13
+  -[Hh]) TYPE=HTTPS ; MATCH="git@" ; FORMULA="$GH_SSH/$GH_HTTPS" ;;
14
+  -[Ss]) TYPE=SSH ; MATCH="https:" ; FORMULA="$GH_HTTPS/$GH_SSH" ;;
15
+  *)
16
+    echo "Usage: `basename $0` -h | -s" 1>&2
17
+    echo -e " \e[0;92m-h\e[0m to switch to HTTPS" 1>&2
18
+    echo -e " \e[0;92m-s\e[0m to switch to SSH" 1>&2
19
+    exit 1
20
+    ;;
21
+esac
22
+
23
+REMOTES=$(git remote -v | egrep "\t$MATCH" | gawk '{print $1 " " $2}' | sort -u | sed  "s/$FORMULA/")
24
+
25
+if [[ -z $REMOTES ]]; then
26
+  echo "Nothing to do." ; exit
27
+fi
28
+
29
+echo "$REMOTES" | xargs -n2 git remote set-url
30
+
31
+echo -n "Remotes set to $TYPE: "
32
+echo "$REMOTES" | gawk '{printf "%s ", $1}'
33
+echo

+ 8
- 0
buildroot/share/git/mfinit View File

@@ -0,0 +1,8 @@
1
+#!/usr/bin/env bash
2
+#
3
+# mfinit
4
+#
5
+# Create the upstream repository for Marlin
6
+#
7
+
8
+git remote add upstream git@github.com:MarlinFirmware/Marlin.git

Loading…
Cancel
Save