Willy-JL 2 лет назад
Родитель
Сommit
129639ded3
3 измененных файлов с 11 добавлено и 6 удалено
  1. 9 4
      .utils/add-subtree.sh
  2. 1 1
      .utils/subtree-subdir-helper.sh
  3. 1 1
      README.md

+ 9 - 4
.utils/add-subtree.sh

@@ -1,14 +1,19 @@
 #!/bin/bash
 set -e
 
-if [ "$1" = "" ] || [ "$2" = "" ] || [ "$3" = "" ]; then
-    echo "Usage: git add-subtree <path> <repo> <branch> [subdir]"
+if [ "$1" = "" ] || [ "$2" = "" ]; then
+    echo "Usage 1: git add-subtree <path> <repo url> <branch> [subdir]"
+    echo "Usage 2: git add-subtree <path> <repo url>/tree/<branch>[/subdir]"
     exit
 fi
 path="${1%/}"
 repo="${2%/}"
-branch="${3}"
-subdir="${4%/}"
+if [ "$3" = "" ]; then
+    read repo branch subdir <<< "$(sed -E "s|(https?://[^/]+)/([^/]+)/([^/]+)/tree/([^/]+)/(.*)|\1/\2/\3 \4 \5|" <<< "${repo}")"
+else
+    branch="${3}"
+    subdir="${4%/}"
+fi
 
 if [ "${subdir}" = "" ]; then
     subdir="/"

+ 1 - 1
.utils/subtree-subdir-helper.sh

@@ -2,7 +2,7 @@
 set -e
 
 if [ "${1}" = "" ] || [ "${2}" = "" ] || [ "${3}" = "" ] || [ "${4}" = "" ] || [ "${5}" = "" ]; then
-    echo "Usage: <path> <repo> <branch> <subdir> <action>"
+    echo "Usage: <path> <repo url> <branch> <subdir> <action>"
     exit
 fi
 path="${1}"

+ 1 - 1
README.md

@@ -21,6 +21,6 @@ That's why the commit history for our repo is so huge, it contains all the commi
 
 To make updating more manageable, we have added another layer on top of subtrees:
 - set it up by running `git config --local include.path ../.utils/gitconfig`
-- add a new app with `git add-subtree <path> <repo> <branch> [subdir]`, this will pull the history and create `path/.gitsubtree` to remember the url, branch and subdir
+- add a new app with `git add-subtree <path> <repo url> <branch> [subdir]`, this will pull the history and create `path/.gitsubtree` to remember the url, branch and subdir
 - run `git update-subtree` to pull updates based on the current subtree directory
 - or run `git bulk-update-subtrees` to do it for all subtrees