diff --git a/lua/git-dashboard-nvim/git.lua b/lua/git-dashboard-nvim/git.lua index b5a9de7..7b8273f 100644 --- a/lua/git-dashboard-nvim/git.lua +++ b/lua/git-dashboard-nvim/git.lua @@ -26,8 +26,8 @@ Git.get_repo_with_owner = function() end Git._parse_repo_and_owner = function(remote_url) - return remote_url:match(".*%..*[:/]([^/]+/[^/.]+)") - or remote_url:match(".*%..*[:/]([^/]+/[^/.]+).git") + return remote_url:match(".*%..*[:/]([^/]+/[^/]+).git") + or remote_url:match(".*%..*[:/]([^/]+/[^/.]+)") or "" end diff --git a/lua/git-dashboard-nvim/heatmap/init.lua b/lua/git-dashboard-nvim/heatmap/init.lua index 9f8b99a..85c0c79 100644 --- a/lua/git-dashboard-nvim/heatmap/init.lua +++ b/lua/git-dashboard-nvim/heatmap/init.lua @@ -15,7 +15,7 @@ Heatmap.generate_heatmap = function(config) local repo_with_owner = Git.get_repo_with_owner() -- owner/repo if repo_with_owner == "" or not repo_with_owner then - return "" + repo_with_owner = vim.fn.getcwd() end local author = config.author @@ -25,10 +25,6 @@ Heatmap.generate_heatmap = function(config) local commits = Git.get_commit_dates(author, config.branch) - if #commits == 0 then - return "" - end - local current_date_info = utils.current_date_info() local base_heatmap = HeatmapUtils.generate_base_heatmap(commits, current_date_info) diff --git a/lua/git-dashboard-nvim/heatmap/utils.lua b/lua/git-dashboard-nvim/heatmap/utils.lua index abe68a2..e956e8e 100644 --- a/lua/git-dashboard-nvim/heatmap/utils.lua +++ b/lua/git-dashboard-nvim/heatmap/utils.lua @@ -183,7 +183,7 @@ HeatmapUtils.generate_ascii_heatmap = function( -- center vertically ascii heatmap if config.centered then - local lines = vim.api.nvim_get_option("lines") + local lines = vim.api.nvim_get_option_value("lines", {}) local ascii_heatmap_lines = vim.split(ascii_heatmap, "\n") local ascii_heatmap_lines_count = #ascii_heatmap_lines local padding = math.floor((lines - ascii_heatmap_lines_count) / 2) diff --git a/tests/unit/git_spec.lua b/tests/unit/git_spec.lua index ad3cd96..6972a11 100644 --- a/tests/unit/git_spec.lua +++ b/tests/unit/git_spec.lua @@ -38,6 +38,22 @@ describe("git", function() assert(repo_with_owner == "juansalvatore/git-dashboard-nvim") end) + it("should parse repo with extra dot in name", function() + local git = require("git-dashboard-nvim.git") + local repo_with_owner = git._parse_repo_and_owner("git@github.com:csessh/.dotfiles.git") + + assert(repo_with_owner ~= nil) + assert(repo_with_owner == "csessh/.dotfiles") + end) + + it("should parse repo with extra dot in name", function() + local git = require("git-dashboard-nvim.git") + local repo_with_owner = git._parse_repo_and_owner("git@github.com:csessh/test.nvim.git") + + assert(repo_with_owner ~= nil) + assert(repo_with_owner == "csessh/test.nvim") + end) + it("should parse repo with owner from github ssh url without .git", function() local git = require("git-dashboard-nvim.git") local repo_with_owner =