mirror of https://github.com/folke/lazy.nvim.git
This commit is contained in:
parent
a39fa0f0ce
commit
615781aebf
|
@ -94,6 +94,7 @@ function M.update(opts)
|
|||
opts = M.opts(opts, { mode = "update" })
|
||||
return M.run({
|
||||
pipeline = {
|
||||
"git.origin",
|
||||
"git.branch",
|
||||
"git.fetch",
|
||||
{ "git.checkout", lockfile = opts.lockfile },
|
||||
|
@ -123,6 +124,7 @@ function M.check(opts)
|
|||
opts = opts or {}
|
||||
return M.run({
|
||||
pipeline = {
|
||||
{ "git.origin", check = true },
|
||||
"git.fetch",
|
||||
"wait",
|
||||
{ "git.log", check = true },
|
||||
|
@ -137,7 +139,10 @@ end
|
|||
function M.log(opts)
|
||||
opts = M.opts(opts, { mode = "log" })
|
||||
return M.run({
|
||||
pipeline = { "git.log" },
|
||||
pipeline = {
|
||||
{ "git.origin", check = true },
|
||||
"git.log",
|
||||
},
|
||||
plugins = function(plugin)
|
||||
return plugin.url and plugin._.installed
|
||||
end,
|
||||
|
|
|
@ -113,6 +113,30 @@ M.branch = {
|
|||
end,
|
||||
}
|
||||
|
||||
-- check and switch origin
|
||||
M.origin = {
|
||||
skip = function(plugin)
|
||||
if not plugin._.installed or plugin._.is_local then
|
||||
return true
|
||||
end
|
||||
local origin = Git.get_origin(plugin.dir)
|
||||
return origin == plugin.url
|
||||
end,
|
||||
---@param opts {check?:boolean}
|
||||
run = function(self, opts)
|
||||
if opts.check then
|
||||
local origin = Git.get_origin(self.plugin.dir)
|
||||
self.error = "Origin has changed:\n"
|
||||
self.error = self.error .. " * old: " .. origin .. "\n"
|
||||
self.error = self.error .. " * new: " .. self.plugin.url .. "\n"
|
||||
self.error = self.error .. "Please run update to fix"
|
||||
return
|
||||
end
|
||||
require("lazy.manage.task.fs").clean.run(self, opts)
|
||||
M.clone.run(self, opts)
|
||||
end,
|
||||
}
|
||||
|
||||
-- fetches all needed origin branches
|
||||
M.fetch = {
|
||||
skip = function(plugin)
|
||||
|
|
Loading…
Reference in New Issue