feat: add function to check if the current directory is a git repository
This commit is contained in:
@@ -218,6 +218,19 @@ function M.get_os(format)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@function Function to check if CWD is a git repo
|
||||||
|
---@param dir? string The directory to check, defaults to CWD
|
||||||
|
---@return boolean is_git_repo true if working directory is a git repository, false otherwise
|
||||||
|
function M.dir_is_git_repo(dir)
|
||||||
|
-- Default to the current working directory if no directory is specified
|
||||||
|
dir = dir or vim.fn.getcwd()
|
||||||
|
|
||||||
|
local result = vim
|
||||||
|
.system({ "git", "-C", dir, "rev-parse", "--is-inside-work-tree" })
|
||||||
|
:wait()
|
||||||
|
return result.code == 0 -- returns true if the command succeeded
|
||||||
|
end
|
||||||
|
|
||||||
---@function Function to send a notification
|
---@function Function to send a notification
|
||||||
---@param message string The message to send
|
---@param message string The message to send
|
||||||
---@param level string|nil The level of the notification (default: "info")
|
---@param level string|nil The level of the notification (default: "info")
|
||||||
|
|||||||
Reference in New Issue
Block a user