summaryrefslogtreecommitdiff
path: root/mix.exs
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-06-20 16:22:01 +0000
committerlain <lain@soykaf.club>2020-06-20 16:22:01 +0000
commit6efd3730c31c9121894c825b1bef87796a67d000 (patch)
tree750e1e948f90d9c2ae294be9348752f4adeba00f /mix.exs
parent31761340fe7246ea9b57c0d0f7e61df85aa2af85 (diff)
parent053c46153076f351c5273c2d6b1fb0843e7b6a6d (diff)
Merge branch 'bugfix/mix.exs-version-dot-git-less' into 'develop'
mix.exs: version git-less (part 2, MacOS-compat) See merge request pleroma/pleroma!2420
Diffstat (limited to 'mix.exs')
-rw-r--r--mix.exs43
1 files changed, 24 insertions, 19 deletions
diff --git a/mix.exs b/mix.exs
index 6040c994e..4d13e95d7 100644
--- a/mix.exs
+++ b/mix.exs
@@ -230,32 +230,37 @@ defmodule Pleroma.Mixfile do
defp version(version) do
identifier_filter = ~r/[^0-9a-z\-]+/i
- # Pre-release version, denoted from patch version with a hyphen
- {tag, tag_err} =
- System.cmd("git", ["describe", "--tags", "--abbrev=0"], stderr_to_stdout: true)
-
- {describe, describe_err} = System.cmd("git", ["describe", "--tags", "--abbrev=8"])
- {commit_hash, commit_hash_err} = System.cmd("git", ["rev-parse", "--short", "HEAD"])
+ {_cmdgit, cmdgit_err} = System.cmd("sh", ["-c", "command -v git"])
git_pre_release =
- cond do
- tag_err == 0 and describe_err == 0 ->
- describe
- |> String.trim()
- |> String.replace(String.trim(tag), "")
- |> String.trim_leading("-")
- |> String.trim()
+ if cmdgit_err == 0 do
+ {tag, tag_err} =
+ System.cmd("git", ["describe", "--tags", "--abbrev=0"], stderr_to_stdout: true)
- commit_hash_err == 0 ->
- "0-g" <> String.trim(commit_hash)
+ {describe, describe_err} = System.cmd("git", ["describe", "--tags", "--abbrev=8"])
+ {commit_hash, commit_hash_err} = System.cmd("git", ["rev-parse", "--short", "HEAD"])
- true ->
- ""
+ # Pre-release version, denoted from patch version with a hyphen
+ cond do
+ tag_err == 0 and describe_err == 0 ->
+ describe
+ |> String.trim()
+ |> String.replace(String.trim(tag), "")
+ |> String.trim_leading("-")
+ |> String.trim()
+
+ commit_hash_err == 0 ->
+ "0-g" <> String.trim(commit_hash)
+
+ true ->
+ nil
+ end
end
# Branch name as pre-release version component, denoted with a dot
branch_name =
- with {branch_name, 0} <- System.cmd("git", ["rev-parse", "--abbrev-ref", "HEAD"]),
+ with 0 <- cmdgit_err,
+ {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,
true <-
@@ -269,7 +274,7 @@ defmodule Pleroma.Mixfile do
branch_name
else
- _ -> "stable"
+ _ -> ""
end
build_name =