feat(credentials): guard login/submit/logout on credential helper

Problem: if no git credential helper is configured, login and
submit silently fail to persist credentials.

Solution: add `has_helper()` to `git_credential.lua` that checks
`git config credential.helper`. Guard the top of `login()`,
`logout()`, and `submit()` with an early-return error. Add a
healthcheck warning when no helper is configured. Add LuaCATS
annotations to all `git_credential` functions.
This commit is contained in:
Barrett Ruth 2026-03-07 19:50:04 -05:00
parent 8348b6195e
commit 5aa2c024e0
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
4 changed files with 57 additions and 0 deletions

View file

@ -71,6 +71,14 @@ function M.login(platform)
return
end
if not git_credential.has_helper() then
logger.log(
'No git credential helper configured. See :help cp-credentials',
{ level = vim.log.levels.ERROR }
)
return
end
local display = constants.PLATFORM_DISPLAY_NAMES[platform] or platform
local existing = git_credential.get(platform) or {}
@ -111,6 +119,14 @@ function M.logout(platform)
)
return
end
if not git_credential.has_helper() then
logger.log(
'No git credential helper configured. See :help cp-credentials',
{ level = vim.log.levels.ERROR }
)
return
end
local display = constants.PLATFORM_DISPLAY_NAMES[platform] or platform
local existing = git_credential.get(platform)
if existing then