From 80367a6d446e31313ca78838622c31993dfa5729 Mon Sep 17 00:00:00 2001
From: Arkerthan <arkerthan@gmail.com>
Date: Fri, 13 Dec 2019 20:21:07 +0100
Subject: [PATCH] compile outside git repo without errors

---
 compile.sh | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/compile.sh b/compile.sh
index 3ab3fc91111..dc9140f965b 100755
--- a/compile.sh
+++ b/compile.sh
@@ -63,12 +63,16 @@ function compile {
 			exit 2
 		esac
 	fi
-	
-	COMMIT=$(git rev-parse --short HEAD) # Find and insert current commit
-	if [[ "$usehash" ]]; then
-		file="bin/FC_pregmod_${COMMIT}.html"
+
+	if [[ -d .git ]]; then
+		COMMIT=$(git rev-parse --short HEAD) # Find and insert current commit
+		if [[ "$usehash" ]]; then
+			file="bin/FC_pregmod_${COMMIT}.html"
+		else
+			sed -Ei "s/build: .releaseID/\0, commit: $COMMIT/" src/gui/mainMenu/AlphaDisclaimer.tw
+			file="bin/FC_pregmod.html"
+		fi
 	else
-		sed -Ei "s/build: .releaseID/\0, commit: $COMMIT/" src/gui/mainMenu/AlphaDisclaimer.tw
 		file="bin/FC_pregmod.html"
 	fi
 
@@ -81,7 +85,9 @@ function compile {
 
 	#Make the output prettier, replacing \t with a tab and \n with a newline
 	sed -i -e '/^.*<div id="store-area".*$/s/\\t/\t/g' -e '/^.*<div id="store-area".*$/s/\\n/\n/g' $file
-	git checkout -- src/gui/mainMenu/AlphaDisclaimer.tw # Revert AlphaDisclaimer for next compilation
+	if [[ -d .git ]]; then
+		git checkout -- src/gui/mainMenu/AlphaDisclaimer.tw # Revert AlphaDisclaimer for next compilation
+	fi
 	echoMessage "Saved to $file."
 }
 
@@ -125,6 +131,10 @@ fi
 [ -n "$java" ] && ./sanityCheck.sh java
 [ -n "$python" ] && ./sanityCheck.sh
 
+if ! [[ -d .git ]]; then
+	echoMessage "No git repository. Git specfific actions disabled."
+fi
+
 #compile
 if [[ "$dry" ]]; then
 	echoMessage "Dry run finished."
-- 
GitLab