Skip to content

Commit 7fe60f9

Browse files
authored
Merge pull request #1752 from NeogitOrg/specs-for-general
2 parents ca19dba + d86fbd7 commit 7fe60f9

File tree

11 files changed

+86
-16
lines changed

11 files changed

+86
-16
lines changed

lefthook.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
skip_output:
22
- meta
33
pre-push:
4-
only:
5-
- ref: master
64
files: "rg --files"
75
parallel: true
86
commands:
@@ -19,7 +17,7 @@ pre-push:
1917
run: typos {files}
2018
lua-types:
2119
glob: "*.lua"
22-
run: llscheck lua/
20+
run: llscheck lua/ || echo {files}
2321
lua-test:
2422
glob: "tests/specs/**/*_spec.lua"
2523
run: nvim --headless -S "./tests/init.lua" || echo {files}
@@ -29,4 +27,23 @@ pre-push:
2927
- GIT_CONFIG_SYSTEM: /dev/null
3028
- NVIM_APPNAME: neogit-test
3129
rspec:
30+
only:
31+
- ref: master
3232
run: bin/specs {files}
33+
pre-commit:
34+
parallel: true
35+
commands:
36+
rubocop:
37+
glob: "*.rb"
38+
run: bundle exec rubocop {staged_files}
39+
selene:
40+
glob: "{lua,plugin}/**/*.lua"
41+
run: selene --config selene/config.toml {staged_files}
42+
stylua:
43+
glob: "*.lua"
44+
run: stylua --check {staged_files}
45+
typos:
46+
run: typos {staged_files}
47+
lua-types:
48+
glob: "*.lua"
49+
run: llscheck lua/

lua/neogit/popups/branch/actions.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ function M.configure_branch()
225225
return
226226
end
227227

228-
BranchConfigPopup.create(branch_name)
228+
BranchConfigPopup.create { branch = branch_name }
229229
end
230230

231231
function M.rename_branch()

lua/neogit/popups/branch_config/init.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@ local M = {}
33
local popup = require("neogit.lib.popup")
44
local git = require("neogit.lib.git")
55
local actions = require("neogit.popups.branch_config.actions")
6+
local notification = require("neogit.lib.notification")
67

7-
function M.create(branch)
8-
branch = branch or git.branch.current()
8+
---@param env table
9+
function M.create(env)
10+
local branch = env.branch or git.branch.current()
11+
12+
if not branch then
13+
notification.error("Cannot infer branch.")
14+
return
15+
end
916

1017
local g_pull_rebase = git.config.get_global("pull.rebase")
1118
local pull_rebase_entry = git.config.get_local("pull.rebase")

lua/neogit/popups/diff/init.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ local actions = require("neogit.popups.diff.actions")
66

77
function M.create(env)
88
local diffview = config.check_integration("diffview")
9-
local commit_selected = env.section.name == "log" and type(env.item.name) == "string"
9+
local commit_selected = (env.section and env.section.name == "log") and type(env.item.name) == "string"
1010

1111
local p = popup
1212
.builder()
1313
:name("NeogitDiffPopup")
1414
:group_heading("Diff")
15-
:action_if(diffview, "d", "this", actions.this)
15+
:action_if(diffview and env.item, "d", "this", actions.this)
1616
:action_if(diffview and commit_selected, "h", "this..HEAD", actions.this_to_HEAD)
1717
:action_if(diffview, "r", "range", actions.range)
1818
:action("p", "paths")

lua/neogit/popups/fetch/actions.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function M.fetch_submodules(_)
125125
end
126126

127127
function M.set_variables()
128-
require("neogit.popups.branch_config").create()
128+
require("neogit.popups.branch_config").create {}
129129
end
130130

131131
return M

lua/neogit/popups/pull/actions.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function M.from_elsewhere(popup)
8686
end
8787

8888
function M.configure()
89-
require("neogit.popups.branch_config").create()
89+
require("neogit.popups.branch_config").create {}
9090
end
9191

9292
return M

lua/neogit/popups/push/actions.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ function M.explicit_refspec(popup)
195195
end
196196

197197
function M.configure()
198-
require("neogit.popups.branch_config").create()
198+
require("neogit.popups.branch_config").create {}
199199
end
200200

201201
return M

lua/neogit/popups/remote/actions.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function M.configure(_)
114114
return
115115
end
116116

117-
RemoteConfigPopup.create(remote_name)
117+
RemoteConfigPopup.create { remote = remote_name }
118118
end
119119

120120
function M.prune_branches(_)

lua/neogit/popups/remote_config/init.lua

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
11
local M = {}
22
local popup = require("neogit.lib.popup")
3+
local notification = require("neogit.lib.notification")
4+
local git = require("neogit.lib.git")
5+
6+
---@param env table
7+
function M.create(env)
8+
local remotes = git.remote.list()
9+
if vim.tbl_isempty(remotes) then
10+
notification.warn("Repo has no configured remotes.")
11+
return
12+
end
13+
14+
local remote = env.remote
15+
16+
if not remote then
17+
if vim.tbl_contains(remotes, "origin") then
18+
remote = "origin"
19+
elseif #remotes == 1 then
20+
remote = remotes[1]
21+
else
22+
notification.error("Cannot infer remote.")
23+
return
24+
end
25+
end
326

4-
function M.create(remote)
527
local p = popup
628
.builder()
729
:name("NeogitRemoteConfigPopup")

spec/general_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# frozen_string_literal: true
2+
3+
RSpec.describe "general things", :git, :nvim do
4+
popups = %w[
5+
bisect branch branch_config cherry_pick commit
6+
diff fetch help ignore log merge pull push rebase
7+
remote remote_config reset revert stash tag worktree
8+
]
9+
10+
popups.each do |popup|
11+
it "can invoke #{popup} popup without status buffer", :with_remote_origin do
12+
nvim.keys("q")
13+
nvim.lua("require('neogit').open({ '#{popup}' })")
14+
sleep(0.1) # Allow popup to open
15+
16+
expect(nvim.filetype).to eq("NeogitPopup")
17+
expect(nvim.errors).to be_empty
18+
end
19+
end
20+
end

0 commit comments

Comments
 (0)