feat: include git status in LvimVersion (#3774)

* feat: include git status in LvimVersion

* refactor: use git describe

* chore: fix comment

* remove unused function
This commit is contained in:
LostNeophyte 2023-01-24 20:02:21 +01:00 committed by GitHub
parent 8ea68830a0
commit fab66b01f6
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 4AEE18F83AFDEB23

View file

@ -126,6 +126,15 @@ function M.get_lvim_tag()
return tag
end
---Get the description of currently checked-out commit of Lunarvim
---@return string|nil
function M.get_lvim_description()
local _, results = git_cmd { args = { "describe", "--dirty", "--always" } }
local description = if_nil(results[1], M.get_lvim_branch())
return description
end
---Get currently running version of Lunarvim
---@return string
function M.get_lvim_version()
@ -133,19 +142,11 @@ function M.get_lvim_version()
local lvim_version
if current_branch ~= "HEAD" or "" then
lvim_version = current_branch .. "-" .. M.get_lvim_current_sha()
lvim_version = current_branch .. "-" .. M.get_lvim_description()
else
lvim_version = "v" .. M.get_lvim_tag()
end
return lvim_version
end
---Get the commit hash of currently checked-out commit of Lunarvim
---@return string|nil
function M.get_lvim_current_sha()
local _, log_results = git_cmd { args = { "log", "--pretty=format:%h", "-1" } }
local abbrev_version = if_nil(log_results[1], "")
return abbrev_version
end
return M