Procházet zdrojové kódy

Fix quotes in scripts and support multiple remotes

Willy-JL před 2 roky
rodič
revize
ccdee90a4a
3 změnil soubory, kde provedl 32 přidání a 31 odebrání
  1. 10 9
      .utils/add-subtree.sh
  2. 14 14
      .utils/subtree-subdir-helper.sh
  3. 8 8
      .utils/update-subtree.sh

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

@@ -5,18 +5,19 @@ if [ "$1" = "" ] || [ "$2" = "" ] || [ "$3" = "" ]; then
     echo "Usage: git add-subtree <path> <repo> <branch> [subdir]"
     exit
 fi
-path=${1%/}
-repo=${2%/}
-branch=${3}
-subdir=${4%/}
+path="${1%/}"
+repo="${2%/}"
+branch="${3}"
+subdir="${4%/}"
 
 if [ "${subdir}" = "" ]; then
-    git subtree add -P ${path} ${repo} ${branch} -m "Add ${path} from ${repo}"
+    subdir="/"
+    git subtree add -P "${path}" "${repo}" "${branch}" -m "Add ${path} from ${repo}"
 else
-    bash .utils/subtree-subdir-helper.sh ${path} ${repo} ${branch} ${subdir} add
+    bash .utils/subtree-subdir-helper.sh "${path}" "${repo}" "${branch}" "${subdir}" add
 fi
 
-gitsubtree=${path}/.gitsubtree
-echo ${repo} ${branch} ${subdir} > ${gitsubtree}
-git add ${gitsubtree}
+gitsubtree="${path}/.gitsubtree"
+echo "${repo} ${branch} ${subdir}" > "${gitsubtree}"
+git add "${gitsubtree}"
 git commit --amend --no-edit

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

@@ -5,18 +5,18 @@ if [ "${1}" = "" ] || [ "${2}" = "" ] || [ "${3}" = "" ] || [ "${4}" = "" ] || [
     echo "Usage: <path> <repo> <branch> <subdir> <action>"
     exit
 fi
-path=${1}
-repo=${2}
-branch=${3}
-subdir=${4}
-action=${5}
+path="${1}"
+repo="${2}"
+branch="${3}"
+subdir="${4}"
+action="${5}"
 
-prev=$(git branch --show-current)
-temp=$(echo ${repo%/} | rev | cut -d/ -f1,2 | rev | tr / -)-${branch}
-fetch=_fetch-${temp}
-split=_split-${temp}-$(echo ${subdir} | tr / -)
-git fetch --no-tags ${repo} ${branch}:${fetch}
-git checkout ${fetch}
-git subtree split -P ${subdir} -b ${split}
-git checkout ${prev}
-git subtree ${action} -P ${path} ${split} -m "${action^} ${path} from ${repo}"
+prev="$(git branch --show-current)"
+temp="$(echo "${repo%/}" | rev | cut -d/ -f1,2 | rev | tr / -)-${branch}"
+fetch="_fetch-${temp}"
+split="_split-${temp}-$(echo "${subdir}" | tr / -)"
+git fetch --no-tags "${repo}" "${branch}:${fetch}"
+git checkout "${fetch}"
+git subtree split -P "${subdir}" -b "${split}"
+git checkout "${prev}"
+git subtree "${action}" -P "${path}" "${split}" -m "${action^} ${path} from ${repo}"

+ 8 - 8
.utils/update-subtree.sh

@@ -1,11 +1,11 @@
 #!/bin/bash
 set -e
 
-path=${GIT_PREFIX%/}
-read repo branch subdir < ${GIT_PREFIX}.gitsubtree
-
-if [ "${subdir}" = "" ]; then
-    git subtree pull -P ${path} ${repo} ${branch} -m "Merge ${path} from ${repo}"
-else
-    bash .utils/subtree-subdir-helper.sh ${path} ${repo} ${branch} ${subdir} merge
-fi
+path="${GIT_PREFIX%/}"
+while read repo branch subdir; do
+    if [ "${subdir}" = "/" ]; then
+        git subtree pull -P "${path}" "${repo}" "${branch}" -m "Merge ${path} from ${repo}"
+    else
+        bash .utils/subtree-subdir-helper.sh "${path}" "${repo}" "${branch}" "${subdir}" merge
+    fi
+done < "${GIT_PREFIX}.gitsubtree"