Просмотр исходного кода

Merge bulk update subtree scripts

Willy-JL 1 год назад
Родитель
Сommit
9808f011f8
4 измененных файлов с 35 добавлено и 38 удалено
  1. 0 13
      .utils/bulk-update-subtrees.sh
  2. 0 23
      .utils/update-subtree.sh
  3. 33 0
      .utils/update-subtrees.sh
  4. 2 2
      README.md

+ 0 - 13
.utils/bulk-update-subtrees.sh

@@ -1,13 +0,0 @@
-#!/bin/bash
-set -e
-
-bash .utils/.check-workdir.sh
-
-shopt -s globstar
-for file in **/.gitsubtree; do
-    subtree="$(dirname "${file}")"
-    echo -e "\n\nUpdating ${subtree}..."
-    bash .utils/update-subtree.sh "${subtree}"
-done
-
-notify-send -a Git -i git "Subtree bulk update finished" "Double check merge commits" &> /dev/null | true

+ 0 - 23
.utils/update-subtree.sh

@@ -1,23 +0,0 @@
-#!/bin/bash
-set -e
-
-bash .utils/.check-workdir.sh
-
-if [ "${1}" = "" ]; then
-    echo "Usage: <path>"
-    exit
-fi
-path="${1}"
-
-while read -u $remote repo branch subdir; do
-    if [ "${repo:0:1}" = "#" ]; then
-        continue
-    fi
-    if [ "${subdir}" = "/" ]; then
-        exec {capture}>&1
-        result="$(git subtree pull -P "${path}" "${repo}" "${branch}" -m "Merge ${path} from ${repo}" 2>&1 | tee /proc/self/fd/$capture)"
-        bash .utils/.check-merge.sh "${path}" "${repo}" "${result}"
-    else
-        bash .utils/.subtree-subdir-helper.sh "${path}" "${repo}" "${branch}" "${subdir}" merge
-    fi
-done {remote}< "${path}/.gitsubtree"

+ 33 - 0
.utils/update-subtrees.sh

@@ -0,0 +1,33 @@
+#!/bin/bash
+set -e
+
+bash .utils/.check-workdir.sh
+
+if [ "${1}" = "" ]; then
+    shopt -s globstar
+    subtrees=(**/.gitsubtree)
+else
+    subtrees=($*)
+fi
+
+for subtree in "${subtrees[@]}"; do
+    if [[ "${subtree}" != */.gitsubtree ]]; then
+        subtree="${subtree}/.gitsubtree"
+    fi
+    path="$(dirname "${subtree}")"
+    echo -e "\n\nUpdating ${path}..."
+    while read -u $remote repo branch subdir; do
+        if [ "${repo:0:1}" = "#" ]; then
+            continue
+        fi
+        if [ "${subdir}" = "/" ]; then
+            exec {capture}>&1
+            result="$(git subtree pull -P "${path}" "${repo}" "${branch}" -m "Merge ${path} from ${repo}" 2>&1 | tee /proc/self/fd/$capture)"
+            bash .utils/.check-merge.sh "${path}" "${repo}" "${result}"
+        else
+            bash .utils/.subtree-subdir-helper.sh "${path}" "${repo}" "${branch}" "${subdir}" merge
+        fi
+    done {remote}< "${subtree}"
+done
+
+notify-send -a Git -i git "Subtree update finished" "Double check merge commits" &> /dev/null | true

+ 2 - 2
README.md

@@ -28,8 +28,8 @@ That's why the commit history for this repo is so huge, it contains all the comm
 
 
 To make updating more manageable, we have added some scripts on top of subtrees:
 To make updating more manageable, we have added some scripts on top of 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
 - 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
+- run `.utils/update-subtrees.sh <path> [path2] [pathN...]` to pull updates for some subtrees
+- or run `.utils/update-subtrees.sh` with no arguments to update all subtrees
 
 
 Most apps have a remote subtree URL for both the original repository, and for any forks / other sources such as [@xMasterX's pack](https://github.com/xMasterX/all-the-plugins).
 Most apps have a remote subtree URL for both the original repository, and for any forks / other sources such as [@xMasterX's pack](https://github.com/xMasterX/all-the-plugins).
 This process is assisted by `.utils/add-subtree.sh`, if the specified subtree path already exists, it will:
 This process is assisted by `.utils/add-subtree.sh`, if the specified subtree path already exists, it will: