فهرست منبع

Ensure we are on a clean branch and workdir

Willy-JL 1 سال پیش
والد
کامیت
bc2116cd85
6فایلهای تغییر یافته به همراه20 افزوده شده و 24 حذف شده
  1. 1 4
      .utils/.check-merge.sh
  2. 15 0
      .utils/.check-workdir.sh
  3. 1 4
      .utils/.subtree-subdir-helper.sh
  4. 1 8
      .utils/add-subtree.sh
  5. 1 4
      .utils/bulk-update-subtrees.sh
  6. 1 4
      .utils/update-subtree.sh

+ 1 - 4
.utils/.check-merge.sh

@@ -1,10 +1,7 @@
 #!/bin/bash
 set -e
 
-if [ "$(git rev-parse --show-prefix)" != "" ]; then
-    echo "Must be in root of git repo!"
-    exit
-fi
+bash .utils/.check-workdir.sh
 
 if [ "${1}" = "" ] || [ "${2}" = "" ]; then
     echo "Usage: <path> <repo url> <merge output>"

+ 15 - 0
.utils/.check-workdir.sh

@@ -0,0 +1,15 @@
+#!/bin/bash
+set -e
+
+if [ "$(git rev-parse --show-prefix)" != "" ]; then
+    echo "Must be in root of git repo!"
+    exit 1
+fi
+if [ "$(git branch --show-current)" = "" ]; then
+    echo "Must be on a branch!"
+    exit 1
+fi
+if ! git diff --quiet || ! git diff --cached --quiet || ! git merge HEAD &> /dev/null; then
+    echo "Workdir must be clean!"
+    exit 1
+fi

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

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

+ 1 - 8
.utils/add-subtree.sh

@@ -1,14 +1,7 @@
 #!/bin/bash
 set -e
 
-if [ "$(git rev-parse --show-prefix)" != "" ]; then
-    echo "Must be in root of git repo!"
-    exit
-fi
-if ! git diff --quiet || ! git diff --cached --quiet || ! git merge HEAD &> /dev/null; then
-    echo "Workdir must be clean!"
-    exit
-fi
+bash .utils/.check-workdir.sh
 
 if [ "$1" = "" ] || [ "$2" = "" ]; then
     echo "Usage 1: <path> <repo url> <branch> [subdir]"

+ 1 - 4
.utils/bulk-update-subtrees.sh

@@ -1,10 +1,7 @@
 #!/bin/bash
 set -e
 
-if [ "$(git rev-parse --show-prefix)" != "" ]; then
-    echo "Must be in root of git repo!"
-    exit
-fi
+bash .utils/.check-workdir.sh
 
 shopt -s globstar
 for file in **/.gitsubtree; do

+ 1 - 4
.utils/update-subtree.sh

@@ -1,10 +1,7 @@
 #!/bin/bash
 set -e
 
-if [ "$(git rev-parse --show-prefix)" != "" ]; then
-    echo "Must be in root of git repo!"
-    exit
-fi
+bash .utils/.check-workdir.sh
 
 if [ "${1}" = "" ]; then
     echo "Usage: <path>"