fix(df): say git is required when the project can't be found
Description
glab dependency-firewall finds the GitLab project from the Git remote, so it needs git. A Beta customer's CI/CD job image had no git, and the error didn't say that git was the problem:
not a git repository: git: exec: "git": executable file not found in $PATH.This MR:
-
Adds a hint to the project lookup error in the package manager commands (
dfcmd.go) and thepackagecommand, only whengitisn't on thePATH:not a git repository: git: exec: "git": executable file not found in $PATH. git is required, so check that it's installed.The check uses
LookPath("git"), likeattestation verifyandcluster agent bootstrapdo for the binaries they need. Other lookup errors, such as a directory with no Git remote, are unchanged. -
States in the help and docs that the command requires
gitin the CI/CD job image.
The alternative, reading the project from CI_PROJECT_PATH, was discussed in the issue and dropped: no other glab command picks its project from CI/CD variables.
Related Issues
Resolves https://gitlab.com/gitlab-org/cli/-/work_items/8741
How has this been tested?
TestBaseRepoErrorSaysGitIsRequiredandTestPackageBaseRepoErrorExitsOnecheck that the hint appears when git is missing.TestBaseRepoErrorWithGitInstalledHasNoGitHintandTestPackageBaseRepoErrorWithGitInstalledHasNoGitHintcheck that it doesn't appear when git is installed.- Ran a built binary: with no git on
PATH, the command exits with the hint. With git installed but outside a repository, it shows the original error without the hint.