diff options
author | Alex S <alex.strizhakov@gmail.com> | 2019-06-15 12:02:21 +0800 |
---|---|---|
committer | Alex S <alex.strizhakov@gmail.com> | 2019-06-15 12:02:21 +0800 |
commit | baf58c12341b79d1df348f8b5e5f0e3d84edc0e6 (patch) | |
tree | adfa2432ce9ace21ab70e34a068d416d8f6d416d | |
parent | 62ffc00a5d5975a75c905bc728feb71cd15a34d3 (diff) | |
download | pleroma-baf58c12341b79d1df348f8b5e5f0e3d84edc0e6.tar.gz |
version generation
-rw-r--r-- | mix.exs | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -176,7 +176,9 @@ defmodule Pleroma.Mixfile do ahead <- String.replace(describe, tag, "") do {String.replace_prefix(tag, "v", ""), if(ahead != "", do: String.trim(ahead))} else - _ -> {nil, nil} + _ -> + {commit_hash, 0} = System.cmd("git", ["rev-parse", "--short", "HEAD"]) + {nil, "-g" <> String.trim(commit_hash)} end if git_tag && version != git_tag do @@ -203,8 +205,18 @@ defmodule Pleroma.Mixfile do string -> "+" <> string end).() - [version, git_pre_release, build] - |> Enum.filter(fn string -> string && string != "" end) - |> Enum.join() + branch_name = + with {branch_name, 0} <- System.cmd("git", ["rev-parse", "--abbrev-ref", "HEAD"]), + true <- branch_name != "master" do + "-" <> String.trim(branch_name) + end + + full_version = + [version, git_pre_release, branch_name, build] + |> Enum.filter(fn string -> string && string != "" end) + |> Enum.join() + + Mix.shell().info("Project version: #{full_version}") + full_version end end |