mobilizon.chapril.org-mobil.../lib/service/git_status.ex
Thomas Citharel ce7b8e05a1
Fallback GitStatus version code to mix env value
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2020-10-23 18:55:47 +02:00

23 lines
610 B
Elixir

defmodule Mobilizon.Service.GitStatus do
@moduledoc """
See https://github.com/CrowdHailer/git_status/
"""
require Logger
@commit (case System.cmd("git", ["describe", "--tags", "--dirty"]) do
{hash, 0} ->
String.trim(hash)
_ ->
# Fallback on Mix version
Logger.warn("Could not read git commit hash, using Mix version code instead.")
Mix.Project.config()[:version]
end)
@doc """
The git commit hash read at compile time, if present
"""
@spec commit :: String.t()
def commit, do: @commit
end