Skip to content

Commit e0c8118

Browse files
committed
fix: Make Commit class use adapter.
1 parent c8b5177 commit e0c8118

File tree

2 files changed

+23
-25
lines changed

2 files changed

+23
-25
lines changed

lua/diffview/vcs/adapters/git/commit.lua

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
local lazy = require("diffview.lazy")
22
local oop = require('diffview.oop')
3-
local utils = require("diffview.utils")
4-
local Commit = require('diffview.vcs.commit').Commit
5-
6-
---@module "diffview.vcs.adapters.git.utils"
7-
local git = lazy.require("diffview.vcs.adapters.git.utils")
8-
9-
---@type ERevType|LazyModule
10-
local RevType = lazy.access("diffview.vcs.rev", "RevType")
113

4+
local Commit = lazy.access("diffview.vcs.commit", "Commit") ---@type Commit|LazyModule
5+
local RevType = lazy.access("diffview.vcs.rev", "RevType") ---@type ERevType|LazyModule
6+
local utils = lazy.require("diffview.utils") ---@module "diffview.utils"
127

138
local M = {}
149

@@ -23,24 +18,24 @@ local M = {}
2318
---@field ref_names string
2419
---@field subject string
2520
---@field body string
26-
local GitCommit = oop.create_class('GitCommit', Commit)
21+
local GitCommit = oop.create_class("GitCommit", Commit.__get())
2722

2823
function GitCommit:init(opt)
2924
GitCommit:super().init(self, opt)
3025
end
3126

3227
---@param rev_arg string
33-
---@param git_toplevel string
28+
---@param adapter GitAdapter
3429
---@return GitCommit?
35-
function GitCommit.from_rev_arg(rev_arg, git_toplevel)
36-
local out, code = git.exec_sync({
30+
function GitCommit.from_rev_arg(rev_arg, adapter)
31+
local out, code = adapter:exec_sync({
3732
"show",
3833
"--pretty=format:%H %P%n%an%n%ad%n%ar%n %s",
3934
"--date=raw",
4035
"--name-status",
4136
rev_arg,
4237
"--",
43-
}, git_toplevel)
38+
}, adapter.ctx.toplevel)
4439

4540
if code ~= 0 then
4641
return
@@ -60,12 +55,12 @@ function GitCommit.from_rev_arg(rev_arg, git_toplevel)
6055
end
6156

6257
---@param rev Rev
63-
---@param git_toplevel string
58+
---@param adapter GitAdapter
6459
---@return GitCommit?
65-
function GitCommit.from_rev(rev, git_toplevel)
60+
function GitCommit.from_rev(rev, adapter)
6661
assert(rev.type == RevType.COMMIT, "Rev must be of type COMMIT!")
6762

68-
return GitCommit.from_rev_arg(rev.commit, git_toplevel)
63+
return GitCommit.from_rev_arg(rev.commit, adapter)
6964
end
7065

7166
function GitCommit.parse_time_offset(iso_date)

lua/diffview/vcs/commit.lua

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
local lazy = require("diffview.lazy")
22
local oop = require("diffview.oop")
3-
local utils = require("diffview.utils")
43

5-
---@type ERevType|LazyModule
6-
local RevType = lazy.access("diffview.vcs.rev", "RevType")
4+
local RevType = lazy.access("diffview.vcs.rev", "RevType") ---@type ERevType|LazyModule
5+
local utils = lazy.require("diffview.utils") ---@module "diffview.utils"
76

87
local M = {}
98

@@ -38,20 +37,24 @@ function Commit:init(opt)
3837
self.iso_date = Commit.time_to_iso(self.time, self.time_offset)
3938
end
4039

40+
---@diagnostic disable: unused-local, missing-return
41+
4142
---@param rev_arg string
42-
---@param toplevel string
43+
---@param adapter VCSAdapter
4344
---@return Commit?
44-
function Commit.from_rev_arg(rev_arg, toplevel)
45-
return
45+
function Commit.from_rev_arg(rev_arg, adapter)
46+
oop.abstract_stub()
4647
end
4748

49+
---@diagnostic enable: unused-local, missing-return
50+
4851
---@param rev Rev
49-
---@param toplevel string
52+
---@param adapter VCSAdapter
5053
---@return Commit?
51-
function Commit.from_rev(rev, toplevel)
54+
function Commit.from_rev(rev, adapter)
5255
assert(rev.type == RevType.COMMIT, "Rev must be of type COMMIT!")
5356

54-
return Commit.from_rev_arg(rev.commit, toplevel)
57+
return Commit.from_rev_arg(rev.commit, adapter)
5558
end
5659

5760
function Commit.parse_time_offset(iso_date)

0 commit comments

Comments
 (0)