Skip to content

Commit a2889f5

Browse files
committed
Add format and lint + workflows
1 parent 3605c7f commit a2889f5

File tree

7 files changed

+418
-336
lines changed

7 files changed

+418
-336
lines changed

.github/workflows/format.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Format
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
format:
7+
name: Stylua
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- run: date +%W > weekly
12+
13+
- name: Restore cache
14+
id: cache
15+
uses: actions/cache@v2
16+
with:
17+
path: |
18+
~/.cargo/bin
19+
key: ${{ runner.os }}-cargo-${{ hashFiles('weekly') }}
20+
21+
- name: Install
22+
if: steps.cache.outputs.cache-hit != 'true'
23+
run: cargo install stylua
24+
25+
- name: Format
26+
run: stylua --check lua/ --config-path=.stylua.toml

.github/workflows/lint.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Lint
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
lint:
7+
name: Luacheck
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Setup
12+
run: |
13+
sudo apt-get update
14+
sudo apt-get install luarocks
15+
sudo luarocks install luacheck
16+
- name: Lint
17+
run: luacheck lua/ --globals vim

.stylua.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
column_width = 80
2+
line_endings = "Unix"
3+
indent_type = "Spaces"
4+
indent_width = 4
5+
quote_style = "AutoPreferDouble"

lua/advanced_git_search/git_utils.lua

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local finders = require("telescope.finders")
44
local previewers = require("telescope.previewers")
55

66
local last_prompt = nil
7-
M = {}
7+
local M = {}
88

99
local split_query_from_author = function(query)
1010
local author = nil
@@ -185,8 +185,12 @@ M.git_diff_previewer_file = function(bufnr)
185185
return {
186186
"git",
187187
"diff",
188-
prev_commit .. ":" .. determine_historic_file_name(prev_commit, bufnr),
189-
commit_hash .. ":" .. determine_historic_file_name(commit_hash, bufnr),
188+
prev_commit
189+
.. ":"
190+
.. determine_historic_file_name(prev_commit, bufnr),
191+
commit_hash
192+
.. ":"
193+
.. determine_historic_file_name(commit_hash, bufnr),
190194
}
191195
end,
192196
})
@@ -195,8 +199,8 @@ end
195199
--- open diff for current file
196200
--- @param commit (string) commit or branch to diff with
197201
M.open_diff_view = function(
198-
commit, --[[optional]]
199-
file_name
202+
commit, --[[optional]]
203+
file_name
200204
)
201205
if file_name ~= nil and file_name ~= "" then
202206
vim.api.nvim_command(":Gvdiffsplit " .. commit .. ":" .. file_name)
@@ -207,10 +211,13 @@ end
207211

208212
--- returns the base branch of a branch (where fork_point is)
209213
M.base_branch = function()
210-
local command =
211-
'git show-branch | sed "s/].*//" | grep "*" | grep -v "$(git rev-parse --abbrev-ref HEAD)" | head -n1 | sed "s/^.*\\[//"'
212-
-- local command =
213-
-- 'git show-branch | sed "s/].*//" | grep "*" | grep -v "$(git rev-parse --abbrev-ref HEAD)" | head -n1 | sed "s/^.*[//"'
214+
local command = [[git show-branch |\
215+
sed "s/].*//" |\
216+
grep "*" |\
217+
grep -v "$(git rev-parse --abbrev-ref HEAD)" |\
218+
head -n1 |\
219+
sed "s/^.*\\[//"]]
220+
214221
local handle = io.popen(command)
215222
local output = handle:read("*a")
216223
handle:close()

0 commit comments

Comments
 (0)