Commit 39a6b68c2d48a83b217b2f9c875684c2442bee1f

Thomas de Grivel 2023-01-23T07:58:05

fix git version

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/lib/shpkg.subr b/lib/shpkg.subr
index 1b07e4d..bbf8148 100644
--- a/lib/shpkg.subr
+++ b/lib/shpkg.subr
@@ -128,9 +128,13 @@ shpkg_src_parent_dir () {
 shpkg_version () {
     SHPKG_REPO_DIR="$(shpkg_dir "$1")"
     SHPKG_REPO_SRC_DIR="${SHPKG_SRC_DIR}/${SHPKG_REPO_DIR}"
-    SHPKG_REPO_HASH="$(git -C "${SHPKG_REPO_SRC_DIR}" show-ref --head HEAD | cut -d ' ' -f 1 | head -n 1)"
-    SHPKG_REPO_HEAD="$(git -C "${SHPKG_REPO_SRC_DIR}" show-ref | grep "${SHPKG_REPO_HASH}" | grep ' refs/heads/' | sed -e 's,^.* refs/heads/,,')"
-    echo "${SHPKG_REPO_HEAD}-${SHPKG_REPO_HASH}"
+    if [ -d "${SHPKG_REPO_SRC_DIR}/.git" ]; then
+        SHPKG_REPO_HASH="$(git -C "${SHPKG_REPO_SRC_DIR}" show-ref --head HEAD | cut -d ' ' -f 1 | head -n 1)"
+        SHPKG_REPO_HEAD="$(git -C "${SHPKG_REPO_SRC_DIR}" show-ref | grep "${SHPKG_REPO_HASH}" | grep ' refs/heads/' | sed -e 's,^.* refs/heads/,,')"
+        echo "${SHPKG_REPO_HEAD}-${SHPKG_REPO_HASH}"
+        return 0
+    fi
+    return 1
 }
 
 # Building from sources