fix(auth): resolve a bare GITEA_TOKEN host in completion and the Git helper

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-12 20:31:09 +02:00
1 parent c22e8550da
commit 048bb291fc
4 files changed
+28 -6

No files matched your search

+4 -5
View File
@@ -40,6 +40,9 @@ func (a *application) gitCredentialCommand() *cobra.Command {
return err
}
environmentHost := a.tokenInstance()
if resolved, err := settings.ResolveHost(environmentHost, snapshot.Hosts.Hosts); environmentHost != "" && err == nil {
environmentHost = resolved
}
instance, err := auth.MatchGitInstance(request, snapshot.Hosts.Hosts, a.options.host, environmentHost)
if err != nil {
return clierr.Wrap(clierr.Usage, err)
@@ -64,11 +67,7 @@ func (a *application) gitCredentialCommand() *cobra.Command {
}
credential := auth.Credential{}
token := a.deps.Getenv("GITEA_TOKEN")
environmentMatches := false
if environmentHost != "" {
normalized, err := settings.NormalizeHost(environmentHost)
environmentMatches = err == nil && normalized == instance
}
environmentMatches := environmentHost != "" && environmentHost == instance
if token != "" && environmentMatches {
actual, err := services.CurrentAccount(cmd.Context(), a.deps.Client(instance, token, host.Insecure))
if err != nil {