diff options
Diffstat (limited to 'lua/lvim/utils')
| -rw-r--r-- | lua/lvim/utils/init.lua | 32 | 
1 files changed, 30 insertions, 2 deletions
| diff --git a/lua/lvim/utils/init.lua b/lua/lvim/utils/init.lua index bf04e149..d7affd4b 100644 --- a/lua/lvim/utils/init.lua +++ b/lua/lvim/utils/init.lua @@ -174,6 +174,34 @@ function utils.log_contains(query)    return false  end -return utils +function utils.generate_plugins_sha(output) +  local list = {} +  output = output or "commits.lua" + +  local function git_cmd(args) +    local Job = require "plenary.job" +    local stderr = {} +    local stdout, ret = Job +      :new({ +        command = "git", +        args = args, +        on_stderr = function(_, data) +          table.insert(stderr, data) +        end, +      }) +      :sync() +    return ret, stdout +  end --- TODO: find a new home for these autocommands +  for name, plugin in pairs(_G.packer_plugins) do +    local retval, latest_sha = git_cmd { "-C", plugin.path, "rev-parse", "@{-1}" } +    if retval == 0 then +      -- replace dashes, remove postfixes and use lowercase +      local normalize_name = (name:gsub("-", "_"):gsub("%.%S+", "")):lower() +      list[normalize_name] = latest_sha[1] +    end +  end +  utils.write_file(output, "local commits = " .. vim.inspect(list), "w") +end + +return utils | 
