diff options
| author | kylo252 <[email protected]> | 2021-11-27 15:22:43 +0100 | 
|---|---|---|
| committer | GitHub <[email protected]> | 2021-11-27 15:22:43 +0100 | 
| commit | 24be0ef1ef36b8cc725655e920104e9676b72f25 (patch) | |
| tree | 4b36a186c893844d6db4b99c5ed553179858f3d0 /lua/lvim/utils | |
| parent | 044b53a6fed7ed2c477870883857a9742a2e1b98 (diff) | |
chore: bump core-plugins version (#1989)
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 | 
