mix: Check .git presence
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Fri, 25 Feb 2022 09:31:42 +0000 (10:31 +0100)
committerFloatingGhost <hannah@coffee-and-dreams.uk>
Wed, 29 Jun 2022 19:43:41 +0000 (20:43 +0100)
mix.exs

diff --git a/mix.exs b/mix.exs
index 8df00154ecaa4475f9680333ea6288c1431350b6..76e84c2b85dde370057bcdc935265872f24a392c 100644 (file)
--- a/mix.exs
+++ b/mix.exs
@@ -248,9 +248,10 @@ defmodule Pleroma.Mixfile do
     identifier_filter = ~r/[^0-9a-z\-]+/i
 
     git_available? = match?({_output, 0}, System.cmd("sh", ["-c", "command -v git"]))
+    dotgit_present? = File.exists?(".git")
 
     git_pre_release =
-      if git_available? do
+      if git_available? and dotgit_present? do
         {tag, tag_err} =
           System.cmd("git", ["describe", "--tags", "--abbrev=0"], stderr_to_stdout: true)
 
@@ -277,6 +278,7 @@ defmodule Pleroma.Mixfile do
     # Branch name as pre-release version component, denoted with a dot
     branch_name =
       with true <- git_available?,
+           true <- dotgit_present?,
            {branch_name, 0} <- System.cmd("git", ["rev-parse", "--abbrev-ref", "HEAD"]),
            branch_name <- String.trim(branch_name),
            branch_name <- System.get_env("PLEROMA_BUILD_BRANCH") || branch_name,