From 3947c6af63fd90d644e90ebf0c06238f0cf89129 Mon Sep 17 00:00:00 2001
From: David Muckle <dvdmuckle@dvdmuckle.xyz>
Date: Sun, 24 Dec 2023 21:42:00 -0500
Subject: [PATCH] Reorder cases

---
 config/__init__.py | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/config/__init__.py b/config/__init__.py
index acd6bbb6..33d531e9 100644
--- a/config/__init__.py
+++ b/config/__init__.py
@@ -137,14 +137,15 @@ def appversion() -> semantic_version.Version:
             shorthash = gitv.read()
 
     else:
-        # Running from source. For Linux, check to see if .gitversion file exists
-        # If so, use it. This is also required for the Flatpak
-        if pathlib.Path(sys.path[0] + "/" + GITVERSION_FILE).exists():
-            with open(pathlib.Path(sys.path[0] + "/" + GITVERSION_FILE), encoding='utf-8') as gitv:
-                shorthash = gitv.read()
-        else:
-            shorthash = git_shorthash_from_head()
-            if shorthash is None:
+        # Running from source. Use git rev-parse --short HEAD
+        # or fall back to .gitversion file if it exists.
+        # This is also required for the Flatpak
+        shorthash = git_shorthash_from_head()
+        if shorthash is None:
+            if pathlib.Path(sys.path[0] + "/" + GITVERSION_FILE).exists():
+                with open(pathlib.Path(sys.path[0] + "/" + GITVERSION_FILE), encoding='utf-8') as gitv:
+                    shorthash = gitv.read()
+            else:
                 shorthash = 'UNKNOWN'
 
     _cached_version = semantic_version.Version(f'{_static_appversion}+{shorthash}')