Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
ffe9fdf
refactor: abstract the git module into a generic vcs module
zegervdv Oct 14, 2022
b9275e1
fixup! refactor: abstract the git module into a generic vcs module
zegervdv Oct 14, 2022
736e431
fixup! refactor: abstract the git module into a generic vcs module
zegervdv Oct 14, 2022
d522de4
fixup! refactor: abstract the git module into a generic vcs module
zegervdv Oct 14, 2022
b892e9e
fixup! refactor: abstract the git module into a generic vcs module
zegervdv Oct 15, 2022
1176adc
fixup! refactor: abstract the git module into a generic vcs module
zegervdv Oct 15, 2022
989609e
fixup! refactor: abstract the git module into a generic vcs module
zegervdv Oct 15, 2022
4e0b8ab
fixup! refactor: abstract the git module into a generic vcs module
zegervdv Oct 15, 2022
1bb63b6
fixup! refactor: abstract the git module into a generic vcs module
zegervdv Oct 15, 2022
66b7d2d
refactor: create adapter base-class and implementations for git and hg
zegervdv Oct 15, 2022
dce8133
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 15, 2022
41420d1
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 15, 2022
d263510
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 15, 2022
60da691
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 16, 2022
22cd83f
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 17, 2022
28e39aa
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 17, 2022
5030543
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 18, 2022
66851ac
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 18, 2022
1070789
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 19, 2022
a6c8725
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 19, 2022
3552f9f
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 19, 2022
4760ccc
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 19, 2022
b30586e
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 19, 2022
00148d8
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 19, 2022
0049d38
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 19, 2022
0ddfde9
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 19, 2022
855da1f
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 21, 2022
9ab91f1
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 21, 2022
0c09f75
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 21, 2022
89d14a6
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 21, 2022
76f3af7
fixup! refactor: create adapter base-class and implementations for gi…
zegervdv Oct 21, 2022
dfb733f
refactor: move FHOptions to GitAdapter
zegervdv Oct 22, 2022
5242380
integrate suggested changes
zegervdv Oct 23, 2022
87d3c36
fixup! integrate suggested changes
zegervdv Oct 23, 2022
aea0d67
fixup! integrate suggested changes
zegervdv Oct 23, 2022
c80ab1f
fixup! integrate suggested changes
zegervdv Oct 23, 2022
59e1503
Move completion to adapter
zegervdv Oct 23, 2022
ade181d
fixup! Move completion to adapter
zegervdv Oct 23, 2022
c175d94
fixup! Move completion to adapter
zegervdv Oct 23, 2022
7811846
refactor: port DiffviewOPen command
zegervdv Oct 24, 2022
8a5d594
fixup! refactor: port DiffviewOPen command
zegervdv Oct 25, 2022
415d0b8
fixup! refactor: port DiffviewOPen command
zegervdv Oct 25, 2022
30328ff
fixup! fixup! refactor: port DiffviewOPen command
zegervdv Oct 26, 2022
24331ec
fixup! fixup! refactor: port DiffviewOPen command
zegervdv Oct 26, 2022
94c4152
fixup! fixup! fixup! refactor: port DiffviewOPen command
zegervdv Oct 29, 2022
c3faf19
refactor: rename git_ctx to adapter
zegervdv Oct 29, 2022
ffd9a9c
refactor: add public methods to VCSAdapter class
zegervdv Oct 29, 2022
d982b83
refactor: clean up duplicate code
zegervdv Oct 29, 2022
089fb7e
refactor: port verify_rev_arg
zegervdv Oct 29, 2022
6c2d1b7
refactor: remove unused code
zegervdv Oct 29, 2022
6a57fb2
refactor: port incremental_line_trace_data
zegervdv Oct 29, 2022
f6b9218
refactor: rename git.utils
zegervdv Oct 29, 2022
15e5759
refactor: implement restore
zegervdv Oct 30, 2022
7ecfbc1
fixup! refactor: implement restore
zegervdv Oct 30, 2022
5d8bd98
fixup! fixup! refactor: implement restore
zegervdv Oct 30, 2022
2147846
refactor: enable merge resolution
zegervdv Oct 30, 2022
6d7ac92
refactor: delete unused file
zegervdv Oct 30, 2022
d5cb5fd
refactor: clean up last references to vcs module
zegervdv Oct 31, 2022
326eb74
fix: return err and toplevel from find_toplevel()
zegervdv Nov 1, 2022
e868102
refactor: apply review comments
zegervdv Nov 2, 2022
9c51e5d
fixup! refactor: apply review comments
zegervdv Nov 3, 2022
02f178d
fixup! refactor: apply review comments
zegervdv Nov 3, 2022
f6bc23c
fixup! refactor: apply review comments
zegervdv Nov 3, 2022
b4ce9b1
fixup! refactor: apply review comments
zegervdv Nov 3, 2022
589d233
refactor: Update CDiffView to use adapter model.
sindrets Nov 4, 2022
cd42ab0
refactor: Simplify `{reset|add}_files()`.
sindrets Nov 4, 2022
e3e0765
fix: Annotations for optional array parameters.
sindrets Nov 4, 2022
24b91d4
feat: Make completion handle failure more gracefully.
sindrets Nov 4, 2022
18ad919
fixup! refactor: Update CDiffView to use adapter model.
sindrets Nov 8, 2022
3b4467d
refactor: address review comments
zegervdv Nov 8, 2022
b5d60db
fixup! refactor: address review comments
zegervdv Nov 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lua/diffview/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local lazy = require("diffview.lazy")
local DiffView = lazy.access("diffview.scene.views.diff.diff_view", "DiffView") ---@type DiffView|LazyModule
local FileHistoryView = lazy.access("diffview.scene.views.file_history.file_history_view", "FileHistoryView") ---@type FileHistoryView|LazyModule
local StandardView = lazy.access("diffview.scene.views.standard.standard_view", "StandardView") ---@type StandardView|LazyModule
local git = lazy.require("diffview.git.utils") ---@module "diffview.git.utils"
local vcs = lazy.require("diffview.vcs.utils") ---@module "diffview.vcs.utils"
local lib = lazy.require("diffview.lib") ---@module "diffview.lib"
local utils = lazy.require("diffview.utils") ---@module "diffview.utils"

Expand Down Expand Up @@ -166,7 +166,7 @@ function M.next_conflict()
local curfile = main.file

if main:is_valid() and curfile:is_valid() then
local conflicts, _, cur_idx = git.parse_conflicts(
local conflicts, _, cur_idx = vcs.parse_conflicts(
api.nvim_buf_get_lines(curfile.bufnr, 0, -1, false),
main.id
)
Expand Down Expand Up @@ -197,7 +197,7 @@ function M.prev_conflict()
local curfile = main.file

if main:is_valid() and curfile:is_valid() then
local conflicts, _, cur_idx = git.parse_conflicts(
local conflicts, _, cur_idx = vcs.parse_conflicts(
api.nvim_buf_get_lines(curfile.bufnr, 0, -1, false),
main.id
)
Expand Down Expand Up @@ -334,7 +334,7 @@ function M.conflict_choose(target)
local curfile = main.file

if main:is_valid() and curfile:is_valid() then
local _, cur = git.parse_conflicts(
local _, cur = vcs.parse_conflicts(
api.nvim_buf_get_lines(curfile.bufnr, 0, -1, false),
main.id
)
Expand Down
33 changes: 15 additions & 18 deletions lua/diffview/api/views/diff/diff_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ local lazy = require("diffview.lazy")
local DiffView = lazy.access("diffview.scene.views.diff.diff_view", "DiffView") ---@type DiffView|LazyModule
local FileEntry = lazy.access("diffview.scene.file_entry", "FileEntry") ---@type FileEntry|LazyModule
local FilePanel = lazy.access("diffview.scene.views.diff.file_panel", "FilePanel") ---@type FilePanel|LazyModule
local Rev = lazy.access("diffview.git.rev", "Rev") ---@type Rev|LazyModule
local RevType = lazy.access("diffview.git.rev", "RevType") ---@type RevType|LazyModule
local Rev = lazy.access("diffview.vcs.adapters.git.rev", "GitRev") ---@type GitRev|LazyModule
local RevType = lazy.access("diffview.vcs.rev", "RevType") ---@type RevType|LazyModule
local async = lazy.require("plenary.async") ---@module "plenary.async"
local git = lazy.require("diffview.git.utils") ---@module "diffview.git.utils"
local vcs = lazy.require("diffview.vcs") ---@module "diffview.vcs"
local logger = lazy.require("diffview.logger") ---@module "diffview.logger"
local oop = lazy.require("diffview.oop") ---@module "diffview.oop"
local utils = lazy.require("diffview.utils") ---@module "diffview.utils"
Expand All @@ -33,16 +33,19 @@ local CDiffView = oop.create_class("CDiffView", DiffView.__get())
function CDiffView:init(opt)
logger.info("[api] Creating a new Custom DiffView.")
self.valid = false
local git_dir = git.git_dir(opt.git_root)

if not git_dir then
local err, adapter = vcs.get_adapter({ top_indicators = { opt.git_root } })

if err then
utils.err(
("Failed to find the git dir for the repository: %s")
("Failed to create an adapter for the repository: %s")
:format(utils.str_quote(opt.git_root))
)
return
end

---@cast adapter -?

-- Fix malformed revs
for _, v in ipairs({ "left", "right" }) do
local rev = opt[v]
Expand All @@ -54,18 +57,13 @@ function CDiffView:init(opt)
self.fetch_files = opt.update_files
self.get_file_data = opt.get_file_data

local git_ctx = {
toplevel = opt.git_root,
dir = git_dir,
}

CDiffView:super().init(self, vim.tbl_extend("force", opt, {
git_ctx = git_ctx,
adapter = adapter,
panel = FilePanel(
git_ctx,
adapter,
self.files,
self.path_args,
self.rev_arg or git.rev_to_pretty_string(opt.left, opt.right)
self.rev_arg or adapter:rev_to_pretty_string(opt.left, opt.right)
),
}))

Expand Down Expand Up @@ -128,7 +126,7 @@ function CDiffView:create_file_entries(files)
{
kind = "staged",
files = files.staged or {},
left = git.head_rev(self.git_ctx.toplevel),
left = self.adapter:head_rev(),
right = Rev(RevType.STAGE, 0),
},
}
Expand All @@ -139,7 +137,7 @@ function CDiffView:create_file_entries(files)
for _, file_data in ipairs(v.files) do
if v.kind == "conflicting" then
table.insert(entries[v.kind], FileEntry.with_layout(CDiffView.get_default_merge_layout(), {
git_ctx = self.git_ctx,
adapter = self.adapter,
path = file_data.path,
oldpath = file_data.oldpath,
status = "U",
Expand All @@ -148,11 +146,10 @@ function CDiffView:create_file_entries(files)
rev_main = Rev(RevType.LOCAL),
rev_theirs = Rev(RevType.STAGE, 3),
rev_base = Rev(RevType.STAGE, 1),
get_data = self.get_file_data,
}))
else
table.insert(entries[v.kind], FileEntry.for_d2(CDiffView.get_default_diff2(), {
git_ctx = self.git_ctx,
adapter = self.adapter,
path = file_data.path,
oldpath = file_data.oldpath,
status = file_data.status,
Expand Down
Loading