Pārlūkot izejas kodu

This didnt work well with submodules

Willy-JL 2 gadi atpakaļ
vecāks
revīzija
60f67941e8

+ 7 - 2
.utils/add-subtree.sh

@@ -1,9 +1,14 @@
 #!/bin/bash
 set -e
 
+if [ "$(git rev-parse --show-prefix)" != "" ]; then
+    echo "Must be in root of git repo!"
+    exit
+fi
+
 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]"
+    echo "Usage 1: <path> <repo url> <branch> [subdir]"
+    echo "Usage 2: <path> <repo url>/tree/<branch>[/subdir]"
     exit
 fi
 path="${1%/}"

+ 6 - 3
.utils/bulk-update-subtrees.sh

@@ -1,10 +1,13 @@
 #!/bin/bash
 set -e
 
+if [ "$(git rev-parse --show-prefix)" != "" ]; then
+    echo "Must be in root of git repo!"
+    exit
+fi
+
 for file in **/.gitsubtree; do
     subtree="$(dirname "${file}")"
     echo -e "\n\nUpdating ${subtree}..."
-    pushd "${subtree}" > /dev/null
-    git update-subtree
-    popd > /dev/null
+    bash .utils/update-subtree.sh "${subtree}"
 done

+ 0 - 4
.utils/gitconfig

@@ -1,4 +0,0 @@
-[alias]
-    add-subtree = "!bash .utils/add-subtree.sh"
-    update-subtree = "!bash .utils/update-subtree.sh"
-    bulk-update-subtrees = "!bash .utils/bulk-update-subtrees.sh"

+ 5 - 0
.utils/subtree-subdir-helper.sh

@@ -1,6 +1,11 @@
 #!/bin/bash
 set -e
 
+if [ "$(git rev-parse --show-prefix)" != "" ]; then
+    echo "Must be in root of git repo!"
+    exit
+fi
+
 if [ "${1}" = "" ] || [ "${2}" = "" ] || [ "${3}" = "" ] || [ "${4}" = "" ] || [ "${5}" = "" ]; then
     echo "Usage: <path> <repo url> <branch> <subdir> <action>"
     exit

+ 12 - 2
.utils/update-subtree.sh

@@ -1,7 +1,17 @@
 #!/bin/bash
 set -e
 
-path="${GIT_PREFIX%/}"
+if [ "$(git rev-parse --show-prefix)" != "" ]; then
+    echo "Must be in root of git repo!"
+    exit
+fi
+
+if [ "${1}" = "" ]; then
+    echo "Usage: <path>"
+    exit
+fi
+path="${1}"
+
 while read repo branch subdir; do
     if [ "${repo:0:1}" = "#" ]; then
         continue
@@ -18,4 +28,4 @@ while read repo branch subdir; do
             sleep 1
         done
     fi
-done < "${GIT_PREFIX}.gitsubtree"
+done < "${path}/.gitsubtree"

+ 3 - 4
README.md

@@ -20,7 +20,6 @@ Subtrees work in a very peculiar way, where they pull and compare commit history
 That's why the commit history for our repo is so huge, it contains all the commits for all the apps, plus our edits.
 
 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 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
+- add a new app with `.utils/add-subtree.sh <path> <repo url> <branch> [subdir]`, this will pull the history and create `path/.gitsubtree` to remember the url, branch and subdir
+- run `.utils/update-subtree.sh <path>` to pull updates for a subtree
+- or run `.utils/bulk-update-subtrees.sh` to do it for all subtrees