mirror of
				https://github.com/folke/lazy.nvim.git
				synced 2025-11-04 00:11:06 +00:00 
			
		
		
		
	feat: git log config
This commit is contained in:
		
					parent
					
						
							
								0233460d54
							
						
					
				
			
			
				commit
				
					
						3e4f84640e
					
				
			
		
					 3 changed files with 22 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -27,6 +27,11 @@ M.defaults = {
 | 
			
		|||
      task = "✔ ",
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  git = {
 | 
			
		||||
    -- defaults for `Lazy log`
 | 
			
		||||
    log = { "-10" }, -- last 10 commits
 | 
			
		||||
    -- log = { "--since=3 days ago" }, -- commits from the last 3 days
 | 
			
		||||
  },
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
M.ns = vim.api.nvim_create_namespace("lazy")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,19 +1,20 @@
 | 
			
		|||
local Util = require("lazy.util")
 | 
			
		||||
local Git = require("lazy.manage.git")
 | 
			
		||||
local Lock = require("lazy.manage.lock")
 | 
			
		||||
local Config = require("lazy.core.config")
 | 
			
		||||
 | 
			
		||||
---@type table<string, LazyTaskDef>
 | 
			
		||||
local M = {}
 | 
			
		||||
 | 
			
		||||
M.log = {
 | 
			
		||||
  ---@param opts {since?: string, updated?:boolean, check?: boolean}
 | 
			
		||||
  ---@param opts {updated?:boolean, check?: boolean}
 | 
			
		||||
  skip = function(plugin, opts)
 | 
			
		||||
    if opts.updated and not (plugin._.updated and plugin._.updated.from ~= plugin._.updated.to) then
 | 
			
		||||
      return true
 | 
			
		||||
    end
 | 
			
		||||
    return not Util.file_exists(plugin.dir .. "/.git")
 | 
			
		||||
  end,
 | 
			
		||||
  ---@param opts {since?: string, updated?:boolean, check?:boolean}
 | 
			
		||||
  ---@param opts {args?: string[], updated?:boolean, check?:boolean}
 | 
			
		||||
  run = function(self, opts)
 | 
			
		||||
    local args = {
 | 
			
		||||
      "log",
 | 
			
		||||
| 
						 | 
				
			
			@ -30,10 +31,8 @@ M.log = {
 | 
			
		|||
      local info = assert(Git.info(self.plugin.dir))
 | 
			
		||||
      local target = assert(Git.get_target(self.plugin))
 | 
			
		||||
      table.insert(args, info.commit .. ".." .. target.commit)
 | 
			
		||||
    elseif opts.since then
 | 
			
		||||
      table.insert(args, "--since=" .. (opts.since or "3 days ago"))
 | 
			
		||||
    else
 | 
			
		||||
      table.insert(args, "-10")
 | 
			
		||||
      vim.list_extend(args, opts.args or Config.options.git.log)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    self:spawn("git", {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue