Skip to content

Commit

Permalink
fix: repository commit hash 를 열때, 해당 repository 이름에 . 이 포함된 경우
Browse files Browse the repository at this point in the history
정상동작하지 않던 이슈 처리

i.e. neogit 등을 실행해서 해당 레포(`.` 포함되어 있어야 함)의 hash 에서 실행하면 재현
  • Loading branch information
deptno committed Oct 15, 2023
1 parent c366ead commit 6833181
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
4 changes: 3 additions & 1 deletion lua/lab/gx/handlers_n/github_commit.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
local is_git_hash = require('lab/gx/lib/is_git_hash')
local remove_suffix = require("lab/gx/lib/remove_suffix")

local handler = function(line, matched)
local git_root = vim.fn.system('git rev-parse --show-toplevel'):gsub('\n', '')
local fail_prefix = 'fatal:'
Expand All @@ -16,7 +18,7 @@ local handler = function(line, matched)

local domain = parts[2]
local username = parts[3]
local repository = vim.fn.fnamemodify(parts[4], ':r')
local repository = remove_suffix('.git', parts[4])

local Job = require("plenary.job")
local command = "open"
Expand Down
4 changes: 3 additions & 1 deletion lua/lab/gx/handlers_n/github_commit_file.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
local is_git_hash = require('lab/gx/lib/is_git_hash')
local remove_suffix = require("lab/gx/lib/remove_suffix")

local handler = function(line, matched)
local git_root = vim.fn.system('git rev-parse --show-toplevel'):gsub('\n', '')
local fail_prefix = 'fatal:'
Expand All @@ -15,7 +17,7 @@ local handler = function(line, matched)

local domain = parts[2]
local username = parts[3]
local repository = vim.fn.fnamemodify(parts[4], ':r')
local repository = remove_suffix('.git', parts[4])

local Job = require("plenary.job")
local command = "open"
Expand Down
8 changes: 2 additions & 6 deletions lua/lab/gx/lib/get_git_remote_info.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
local remove_suffix = function (suffix, name)
if name:sub(-#suffix) == suffix then
return name:sub(1, -(#suffix + 1))
end
return name
end
local remove_suffix = require("lab/gx/lib/remove_suffix")

local get_git_remote_info = function (cwd)
local command = type(cwd) == 'string'
and string.format("git -C %s remote -v | head -1 | awk '{print $2}'", cwd)
Expand Down
8 changes: 8 additions & 0 deletions lua/lab/gx/lib/remove_suffix.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
local remove_suffix = function (suffix, name)
if name:sub(-#suffix) == suffix then
return name:sub(1, -(#suffix + 1))
end
return name
end

return remove_suffix

0 comments on commit 6833181

Please sign in to comment.