| 1 | package lfshttpscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/ |
| 2 | |
| 3 | import ( |
| 4 | "bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/" |
| 5 | "encoding/jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/" |
| 6 | goerrorsscip-go gomod github.com/golang/go/src go1.25.0 errors/ "errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/" |
| 7 | "os/execscip-go gomod github.com/golang/go/src go1.25.0 `os/exec`/" |
| 8 | "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/" |
| 9 | "syncscip-go gomod github.com/golang/go/src go1.25.0 sync/" |
| 10 | "timescip-go gomod github.com/golang/go/src go1.25.0 time/" |
| 11 | |
| 12 | "github.com/git-lfs/git-lfs/v3/configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/" |
| 13 | "github.com/git-lfs/git-lfs/v3/sshscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/ssh`/" |
| 14 | "github.com/git-lfs/git-lfs/v3/subprocessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/subprocess`/" |
| 15 | "github.com/git-lfs/git-lfs/v3/toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/" |
| 16 | "github.com/rubyist/tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/" |
| 17 | ) |
| 18 | |
| 19 | // sshAuthenticateNotFoundExitCode is the conventional POSIX shell exit code |
| 20 | // returned when a command cannot be found. When the remote `ssh` invocation |
| 21 | // exits with this status, we treat the `git-lfs-authenticate` command as |
| 22 | // unavailable on the server and fall back to the guessed LFS endpoint rather |
| 23 | // than treating the failure as fatal. |
| 24 | const sshAuthenticateNotFoundExitCodescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthenticateNotFoundExitCode. = 127 |
| 25 | |
| 26 | // sshAuthenticateNotFoundMessages are case-insensitive substrings of the |
| 27 | // stderr output produced when `git-lfs-authenticate` is not available on the |
| 28 | // server. Not every server uses the conventional 127 exit code: Gerrit, for |
| 29 | // example, runs the command through a restricted shell that returns a generic |
| 30 | // exit code 1 with a "not found"-style message. The substrings are anchored |
| 31 | // to the command name so that unrelated "not found" errors (such as a missing |
| 32 | // repository) are not misclassified. |
| 33 | var sshAuthenticateNotFoundMessagesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthenticateNotFoundMessages. = []string{ |
| 34 | "git-lfs-authenticate: not found", // Gerrit |
| 35 | "git-lfs-authenticate: command not found", // bash, sh |
| 36 | "git-lfs-authenticate: no such file", // direct exec by path |
| 37 | "command not found: git-lfs-authenticate", // zsh |
| 38 | } |
| 39 | |
| 40 | // isSSHAuthenticateUnavailable reports whether the error and captured stderr |
| 41 | // from running `git-lfs-authenticate` over SSH indicate that the command is |
| 42 | // not available on the server, in which case Git LFS should fall back to the |
| 43 | // guessed LFS endpoint instead of failing the request. |
| 44 | func isSSHAuthenticateUnavailablescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/isSSHAuthenticateUnavailable().(err error, stderr string) bool { |
| 45 | var exitErr *execscip-go gomod github.com/golang/go/src go1.25.0 `os/exec`/.ExitErrorscip-go gomod github.com/golang/go/src go1.25.0 `os/exec`/ExitError# |
| 46 | if !goerrorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Asscip-go gomod github.com/golang/go/src go1.25.0 errors/As().(err, &exitErr) { |
| 47 | // The command never ran to completion (e.g. the local ssh |
| 48 | // binary is missing); this is a genuine error, not an |
| 49 | // unavailable git-lfs-authenticate command. |
| 50 | return false |
| 51 | } |
| 52 | |
| 53 | if exitErr.ExitCodescip-go gomod github.com/golang/go/src go1.25.0 os/ProcessState#ExitCode().() == sshAuthenticateNotFoundExitCodescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthenticateNotFoundExitCode. { |
| 54 | return true |
| 55 | } |
| 56 | |
| 57 | if exitErr.ExitCodescip-go gomod github.com/golang/go/src go1.25.0 os/ProcessState#ExitCode().() != 0 { |
| 58 | msg := stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.25.0 strings/ToLower().(stderr) |
| 59 | for _, needle := range sshAuthenticateNotFoundMessagesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthenticateNotFoundMessages. { |
| 60 | if stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Containsscip-go gomod github.com/golang/go/src go1.25.0 strings/Contains().(msg, needle) { |
| 61 | return true |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | return false |
| 66 | } |
| 67 | |
| 68 | // sshAuthenticateUnavailableError indicates that the `git-lfs-authenticate` |
| 69 | // command is not available on the SSH server. Callers should fall back to the |
| 70 | // guessed LFS endpoint per the server discovery specification instead of |
| 71 | // failing the request. |
| 72 | type sshAuthenticateUnavailableErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthenticateUnavailableError# struct { |
| 73 | errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthenticateUnavailableError#err. error |
| 74 | } |
| 75 | |
| 76 | func (e *sshAuthenticateUnavailableErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthenticateUnavailableError#) Errorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthenticateUnavailableError#Error().() string { |
| 77 | return e.errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthenticateUnavailableError#err..Error() |
| 78 | } |
| 79 | |
| 80 | func (e *sshAuthenticateUnavailableErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthenticateUnavailableError#) Unwrapscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthenticateUnavailableError#Unwrap().() error { |
| 81 | return e.errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthenticateUnavailableError#err. |
| 82 | } |
| 83 | |
| 84 | type SSHResolverscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/SSHResolver# interface { |
| 85 | Resolvescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/SSHResolver#Resolve.(Endpointscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Endpoint#, string) (sshAuthResponsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#, error) |
| 86 | } |
| 87 | |
| 88 | func withSSHCachescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/withSSHCache().(ssh SSHResolverscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/SSHResolver#) SSHResolverscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/SSHResolver# { |
| 89 | return &sshCachescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshCache#{sshscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshCache#ssh.: ssh} |
| 90 | } |
| 91 | |
| 92 | type sshCachescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshCache# struct { |
| 93 | endpointsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshCache#endpoints. syncscip-go gomod github.com/golang/go/src go1.25.0 sync/.Mapscip-go gomod github.com/golang/go/src go1.25.0 sync/Map# // map[string]*sshAuthResponse |
| 94 | sshscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshCache#ssh. SSHResolverscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/SSHResolver# |
| 95 | } |
| 96 | |
| 97 | func (c *sshCachescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshCache#) Resolvescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshCache#Resolve().(e Endpointscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Endpoint#, method string) (sshAuthResponsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#, error) { |
| 98 | if len(e.SSHMetadatascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Endpoint#SSHMetadata..UserAndHostscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/ssh`/SSHMetadata#UserAndHost.) == 0 { |
| 99 | return sshAuthResponsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#{}, nil |
| 100 | } |
| 101 | |
| 102 | key := stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.25.0 strings/Join().([]string{e.SSHMetadatascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Endpoint#SSHMetadata..UserAndHostscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/ssh`/SSHMetadata#UserAndHost., e.SSHMetadatascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Endpoint#SSHMetadata..Portscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/ssh`/SSHMetadata#Port., e.SSHMetadatascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Endpoint#SSHMetadata..Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/ssh`/SSHMetadata#Path., method}, "//") |
| 103 | if val, ok := c.endpointsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshCache#endpoints..Loadscip-go gomod github.com/golang/go/src go1.25.0 sync/Map#Load().(key); ok { |
| 104 | res := val.(*sshAuthResponsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#) |
| 105 | if _, expired := res.IsExpiredWithinscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#IsExpiredWithin().(5 * timescip-go gomod github.com/golang/go/src go1.25.0 time/.Secondscip-go gomod github.com/golang/go/src go1.25.0 time/Second.); !expired { |
| 106 | tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/.Printfscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/Printf().("ssh cache: %s git-lfs-authenticate %s %s", |
| 107 | e.SSHMetadatascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Endpoint#SSHMetadata..UserAndHostscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/ssh`/SSHMetadata#UserAndHost., e.SSHMetadatascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Endpoint#SSHMetadata..Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/ssh`/SSHMetadata#Path., endpointOperationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/endpointOperation().(e, method)) |
| 108 | return *res, nil |
| 109 | } else { |
| 110 | tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/.Printfscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/Printf().("ssh cache expired: %s git-lfs-authenticate %s %s", |
| 111 | e.SSHMetadatascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Endpoint#SSHMetadata..UserAndHostscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/ssh`/SSHMetadata#UserAndHost., e.SSHMetadatascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Endpoint#SSHMetadata..Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/ssh`/SSHMetadata#Path., endpointOperationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/endpointOperation().(e, method)) |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | res, err := c.sshscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshCache#ssh..Resolvescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/SSHResolver#Resolve.(e, method) |
| 116 | if err == nil { |
| 117 | c.endpointsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshCache#endpoints..Storescip-go gomod github.com/golang/go/src go1.25.0 sync/Map#Store().(key, &res) |
| 118 | } |
| 119 | return res, err |
| 120 | } |
| 121 | |
| 122 | type sshAuthResponsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse# struct { |
| 123 | Messagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#Message. string `json:"-"` |
| 124 | Hrefscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#Href. string `json:"href"` |
| 125 | Headerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#Header. map[string]string `json:"header"` |
| 126 | ExpiresAtscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#ExpiresAt. timescip-go gomod github.com/golang/go/src go1.25.0 time/.Timescip-go gomod github.com/golang/go/src go1.25.0 time/Time# `json:"expires_at"` |
| 127 | ExpiresInscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#ExpiresIn. timescip-go gomod github.com/golang/go/src go1.25.0 time/.Durationscip-go gomod github.com/golang/go/src go1.25.0 time/Duration# `json:"expires_in"` |
| 128 | |
| 129 | createdAtscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#createdAt. timescip-go gomod github.com/golang/go/src go1.25.0 time/.Timescip-go gomod github.com/golang/go/src go1.25.0 time/Time# |
| 130 | } |
| 131 | |
| 132 | func (r *sshAuthResponsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#) IsExpiredWithinscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#IsExpiredWithin().(d timescip-go gomod github.com/golang/go/src go1.25.0 time/.Durationscip-go gomod github.com/golang/go/src go1.25.0 time/Duration#) (timescip-go gomod github.com/golang/go/src go1.25.0 time/.Timescip-go gomod github.com/golang/go/src go1.25.0 time/Time#, bool) { |
| 133 | return toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.IsExpiredAtOrInscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/IsExpiredAtOrIn().(r.createdAtscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#createdAt., d, r.ExpiresAtscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#ExpiresAt., |
| 134 | timescip-go gomod github.com/golang/go/src go1.25.0 time/.Durationscip-go gomod github.com/golang/go/src go1.25.0 time/Duration#(r.ExpiresInscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#ExpiresIn.)*timescip-go gomod github.com/golang/go/src go1.25.0 time/.Secondscip-go gomod github.com/golang/go/src go1.25.0 time/Second.) |
| 135 | } |
| 136 | |
| 137 | type sshAuthClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthClient# struct { |
| 138 | osscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthClient#os. configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.Environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Environment# |
| 139 | gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthClient#git. configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.Environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Environment# |
| 140 | } |
| 141 | |
| 142 | func (c *sshAuthClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthClient#) Resolvescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthClient#Resolve().(e Endpointscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Endpoint#, method string) (sshAuthResponsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#, error) { |
| 143 | res := sshAuthResponsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#{} |
| 144 | if len(e.SSHMetadatascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Endpoint#SSHMetadata..UserAndHostscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/ssh`/SSHMetadata#UserAndHost.) == 0 { |
| 145 | return res, nil |
| 146 | } |
| 147 | |
| 148 | exe, args, _, _ := sshscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/ssh`/.GetLFSExeAndArgsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/ssh`/GetLFSExeAndArgs().(c.osscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthClient#os., c.gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthClient#git., &e.SSHMetadatascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Endpoint#SSHMetadata., "git-lfs-authenticate", endpointOperationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/endpointOperation().(e, method), false, "") |
| 149 | cmd, err := subprocessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/subprocess`/.ExecCommandscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/subprocess`/ExecCommand().(exe, args...) |
| 150 | if err != nil { |
| 151 | return res, err |
| 152 | } |
| 153 | |
| 154 | // Save stdout and stderr in separate buffers |
| 155 | var outbuf, errbuf bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer# |
| 156 | cmd.Stdoutscip-go gomod github.com/golang/go/src go1.25.0 `os/exec`/Cmd#Stdout. = &outbuf |
| 157 | cmd.Stderrscip-go gomod github.com/golang/go/src go1.25.0 `os/exec`/Cmd#Stderr. = &errbuf |
| 158 | |
| 159 | now := timescip-go gomod github.com/golang/go/src go1.25.0 time/.Nowscip-go gomod github.com/golang/go/src go1.25.0 time/Now().() |
| 160 | |
| 161 | // Execute command |
| 162 | err = cmd.Startscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/subprocess`/Cmd#Start().() |
| 163 | if err == nil { |
| 164 | err = cmd.Waitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/subprocess`/Cmd#Wait().() |
| 165 | } |
| 166 | |
| 167 | // Processing result |
| 168 | if err != nil { |
| 169 | res.Messagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#Message. = stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.25.0 strings/TrimSpace().(errbuf.Stringscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#String().()) |
| 170 | |
| 171 | // If the git-lfs-authenticate command is not available on the |
| 172 | // server, signal this distinctly so the caller can fall back to |
| 173 | // the guessed LFS endpoint instead of failing outright. This |
| 174 | // covers both the conventional command-not-found exit code (127) |
| 175 | // and servers such as Gerrit that return a generic exit code |
| 176 | // with a "not found"-style message. |
| 177 | if isSSHAuthenticateUnavailablescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/isSSHAuthenticateUnavailable().(err, res.Messagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#Message.) { |
| 178 | err = &sshAuthenticateUnavailableErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthenticateUnavailableError#{errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthenticateUnavailableError#err.: err} |
| 179 | } |
| 180 | } else { |
| 181 | err = jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/Unmarshal().(outbuf.Bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#Bytes().(), &res) |
| 182 | if res.ExpiresInscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#ExpiresIn. == 0 && res.ExpiresAtscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#ExpiresAt..IsZeroscip-go gomod github.com/golang/go/src go1.25.0 time/Time#IsZero().() { |
| 183 | ttl := c.gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthClient#git..Int64scip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Environment#Int64.("lfs.defaulttokenttl", 0) |
| 184 | if ttl < 0 { |
| 185 | ttl = 0 |
| 186 | } |
| 187 | res.ExpiresInscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#ExpiresIn. = timescip-go gomod github.com/golang/go/src go1.25.0 time/.Durationscip-go gomod github.com/golang/go/src go1.25.0 time/Duration#(ttl) |
| 188 | } |
| 189 | res.createdAtscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/sshAuthResponse#createdAt. = now |
| 190 | } |
| 191 | |
| 192 | return res, err |
| 193 | } |