Skip to content

Commit

Permalink
feat: git log config
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Nov 29, 2022
1 parent 0233460 commit 3e4f846
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

- [x] support for Plugin.lock
- [ ] health checks: check merge conflicts async
- [ ] defaults for git log
- [x] defaults for git log
- [x] view keybindings for update/clean/...
- [x] add profiler to view
- [x] add buttons for actions
Expand All @@ -38,6 +38,17 @@
- [ ] use uv file watcher to check for config changes
- [x] clear errors
- [x] add support for versions `git tag --sort v:refname`
- [ ] rename requires to deps
- [x] rename requires to dependencies
- [x] move tasks etc to Plugin.state
- [ ] allow setting up plugins through config
- [ ] handlers imply opt
- [ ] dependencies imply opt for deps
- [x] fix local plugin spec

## 📦 Differences with Packer

- **Plugin Spec**:

- `setup` => `init`
- `requires` => `dependencies`
- `as` => `name`
5 changes: 5 additions & 0 deletions lua/lazy/core/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
9 changes: 4 additions & 5 deletions lua/lazy/manage/task/git.lua
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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", {
Expand Down

0 comments on commit 3e4f846

Please sign in to comment.