GitLabgitlab-org

cli

main
ply6 git calls208 ms102 KiB4 cachedprotocol v2
630 lines20 KiBRaw
1package api
3import (
4 "context"
5 "crypto/tls"
6 "errors"
7 "fmt"
8 "io"
9 "net"
10 "net/http"
11 "net/url"
12 "os"
13 "slices"
14 "strconv"
15 "strings"
16 "time"
18 "github.com/hashicorp/go-retryablehttp"
20 gitlab "gitlab.com/gitlab-org/api/client-go/v3"
22 "gitlab.com/gitlab-org/cli/internal/config"
23 "gitlab.com/gitlab-org/cli/internal/dbg"
24 "gitlab.com/gitlab-org/cli/internal/glinstance"
25 "gitlab.com/gitlab-org/cli/internal/oauth2"
26 "gitlab.com/gitlab-org/cli/internal/utils"
29// ClientOption represents a function that configures a Client
30type ClientOption func(*Client) error
32type BuildInfo struct {
33 Version, Commit, Platform, Architecture string
34 CodingAgent string
37func (i BuildInfo) UserAgent() string {
38 ua := fmt.Sprintf("glab/%s (%s, %s)", i.Version, i.Platform, i.Architecture)
39 if i.CodingAgent != "" {
40 ua += " Coding-Agent/" + i.CodingAgent
41 }
42 return ua
45// Client represents an argument to NewClient
46type Client struct {
47 // gitlabClient represents GitLab API client.
48 gitlabClient *gitlab.Client
49 // internal http client
50 httpClient *http.Client
51 // custom certificate
52 caFile string
53 // client certificate files
54 clientCertFile string
55 clientKeyFile string
56 clientCertPassword func() (string, error)
58 baseURL string
59 authSource gitlab.AuthSource
61 allowInsecure bool
63 userAgent string
65 customHeaders map[string]string
66 customHeaderExtraHosts map[string]struct{}
67 // proxyURL is nil when the proxy comes from the environment.
68 proxyURL *url.URL
69 transports *TransportCache
72func (c *Client) HTTPClient() *http.Client {
73 return c.httpClient
76// AuthSource returns the auth source
77// TODO: clarify use cases for this.
78func (c *Client) AuthSource() gitlab.AuthSource {
79 return c.authSource
82func (c *Client) BaseURL() string {
83 return c.baseURL
86// Lab returns the initialized GitLab client.
87func (c *Client) Lab() *gitlab.Client {
88 return c.gitlabClient
91var secureCipherSuites = []uint16{
92 tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
93 tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
94 tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
95 tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
98type newAuthSource func(c *http.Client) (authSource gitlab.AuthSource, err error)
100// NewClient initializes a api client for use throughout glab.
101func NewClient(newAuthSource newAuthSource, options ...ClientOption) (*Client, error) {
102 // 0. initialize empty Client
103 client := &Client{}
105 // 1. apply provided option functions to populate client
106 for _, option := range options {
107 if err := option(client); err != nil {
108 return nil, fmt.Errorf("failed to apply client option: %w", err)
109 }
110 }
112 // 2. initialize HTTP client used by the auth source and by the GitLab client
113 if err := client.initializeHTTPClient(); err != nil {
114 return nil, err
115 }
117 // 3. initialize the auth source
118 // We need to delay this because sources like OAuth2 need a valid
119 // HTTP client to refresh the token.
120 authSource, err := newAuthSource(client.httpClient)
121 if err != nil {
122 return nil, fmt.Errorf("failed to initialize auth source: %w", err)
123 }
124 client.authSource = authSource
126 // 4. initialize the GitLab client
127 if client.gitlabClient != nil {
128 return client, nil
129 }
131 if client.authSource == nil {
132 return nil, errors.New("unable to initialize GitLab Client because no authentication source is provided. Login first")
133 }
135 gitlabClient, err := gitlab.NewAuthSourceClient(
136 client.authSource,
137 gitlab.WithHTTPClient(client.httpClient),
138 gitlab.WithBaseURL(client.baseURL),
139 gitlab.WithUserAgent(client.userAgent),
140 // A retried POST can duplicate a resource the server already created.
141 gitlab.WithOnlyIdempotentRetries(),
142 )
143 if err != nil {
144 return nil, fmt.Errorf("failed to initialize GitLab client: %w", err)
145 }
147 client.gitlabClient = gitlabClient
148 return client, nil
151func (c *Client) initializeHTTPClient() error {
152 if c.httpClient != nil {
153 return nil
154 }
156 u, err := url.Parse(c.baseURL)
157 if err != nil {
158 return err
159 }
160 clientCertPassword, err := pkcs12Password(c.clientCertFile, c.clientKeyFile, c.clientCertPassword)
161 if err != nil {
162 return err
163 }
165 key := transportKey{
166 caFile: c.caFile,
167 clientCertFile: c.clientCertFile,
168 clientKeyFile: c.clientKeyFile,
169 clientCertPassword: clientCertPassword,
170 insecure: c.allowInsecure,
171 gitlabCom: !glinstance.IsSelfHosted(u.Hostname()),
172 }
173 if c.proxyURL != nil {
174 key.proxyURL = c.proxyURL.String()
175 }
177 var rt http.RoundTripper
178 if c.transports != nil {
179 t, err := c.transports.transport(key)
180 if err != nil {
181 return err
182 }
183 rt = &pooledTransport{rt: t}
184 } else {
185 t, err := newTransport(key)
186 if err != nil {
187 return err
188 }
189 rt = t
190 }
192 if enabled, found := utils.IsEnvVarEnabled("GLAB_DEBUG_HTTP"); found && enabled {
193 rt = &debugTransport{rt: rt, w: os.Stderr}
194 }
196 if len(c.customHeaders) > 0 {
197 allowedHosts := make(map[string]struct{}, len(c.customHeaderExtraHosts)+1)
198 for host := range c.customHeaderExtraHosts {
199 allowedHosts[strings.ToLower(host)] = struct{}{}
200 }
201 allowedHosts[strings.ToLower(u.Host)] = struct{}{}
202 rt = &customHeadersTransport{rt: rt, headers: c.customHeaders, allowedHosts: allowedHosts}
203 }
205 c.httpClient = &http.Client{Transport: rt, CheckRedirect: refuseMethodChangingRedirect}
206 return nil
209// WithProxy routes requests through proxyURL. A nil proxyURL uses the proxy
210// from the environment.
211func WithProxy(proxyURL *url.URL) ClientOption {
212 return func(c *Client) error {
213 c.proxyURL = proxyURL
214 return nil
215 }
218// WithCustomHeaders sets custom headers for requests to the client's base URL.
219// extraHosts covers destinations the base URL does not, notably the OAuth refresh
220// endpoint, which uses the configured host even when api_host points elsewhere.
221func WithCustomHeaders(headers map[string]string, extraHosts ...string) ClientOption {
222 return func(c *Client) error {
223 c.customHeaders = headers
224 c.customHeaderExtraHosts = make(map[string]struct{}, len(extraHosts))
225 for _, host := range extraHosts {
226 c.customHeaderExtraHosts[strings.ToLower(host)] = struct{}{}
227 }
228 return nil
229 }
232// WithCustomCA configures the client to use a custom CA certificate
233func WithCustomCA(caFile string) ClientOption {
234 return func(c *Client) error {
235 c.caFile = caFile
236 return nil
237 }
240// WithClientCertificate configures the client to use client certificates for mTLS.
241// An empty keyFile means certFile is tried as a PKCS#12 bundle, and if it is not
242// one, no certificate is sent. password is called only for a bundle that needs one.
243func WithClientCertificate(certFile, keyFile string, password func() (string, error)) ClientOption {
244 return func(c *Client) error {
245 c.clientCertFile = certFile
246 c.clientKeyFile = keyFile
247 c.clientCertPassword = password
248 return nil
249 }
252// WithSafeRetries overrides gitlab.WithOnlyIdempotentRetries and
253// gitlab.WithoutRetries for one request, so a POST or PATCH is also retried on
254// 5xx and on network errors after the request was written. Use it only for a
255// request that is safe to send twice.
256func WithSafeRetries() gitlab.RequestOptionFunc {
257 return gitlab.WithRequestRetry(safeRetryPolicy)
260func safeRetryPolicy(ctx context.Context, resp *http.Response, err error) (bool, error) {
261 // An unknown host stays unknown, so match client-go and fail at once.
262 var dnsErr *net.DNSError
263 if errors.As(err, &dnsErr) && dnsErr.IsNotFound {
264 return false, err
265 }
266 return retryablehttp.DefaultRetryPolicy(ctx, resp, err)
269// WithInsecureSkipVerify configures the client to skip TLS verification
270func WithInsecureSkipVerify(skip bool) ClientOption {
271 return func(c *Client) error {
272 c.allowInsecure = skip
273 return nil
274 }
277// WithHTTPClient configures the HTTP client
278func WithHTTPClient(httpClient *http.Client) ClientOption {
279 return func(c *Client) error {
280 c.httpClient = httpClient
281 return nil
282 }
285// WithGitLabClient configures the GitLab client
286func WithGitLabClient(client *gitlab.Client) ClientOption {
287 return func(c *Client) error {
288 c.gitlabClient = client
289 return nil
290 }
293// WithBaseURL configures the base URL for the GitLab instance
294func WithBaseURL(baseURL string) ClientOption {
295 return func(c *Client) error {
296 c.baseURL = baseURL
297 return nil
298 }
301// WithUserAgent configures the user agent to use
302func WithUserAgent(userAgent string) ClientOption {
303 return func(c *Client) error {
304 c.userAgent = userAgent
305 return nil
306 }
309// FromConfigOption customizes how NewClientFromConfig resolves credentials
310// out of config and how it builds the client. Distinct from ClientOption,
311// which configures the client that has already been built: this affects
312// resolution that happens before a Client exists.
313type FromConfigOption func(*fromConfigOptions)
315type fromConfigOptions struct {
316 // searchEnvForIdentity controls whether the access token and the
317 // is_oauth2 flag may come from the environment (GITLAB_TOKEN,
318 // GITLAB_ACCESS_TOKEN, GLAB_IS_OAUTH2) in addition to config. job_token
319 // is deliberately excluded from this option: CI_JOB_TOKEN authentication
320 // must keep working under CI auto-login regardless.
321 searchEnvForIdentity bool
323 withoutAuthentication bool
325 transports *TransportCache
328// WithoutTokenFromEnvironment resolves the access token and the is_oauth2
329// flag from config only, ignoring GITLAB_TOKEN, GITLAB_ACCESS_TOKEN, and
330// GLAB_IS_OAUTH2.
331//
332// Use it wherever glab acts on behalf of another process that inherits the
333// user's shell environment, such as a Docker credential helper, so a stray
334// environment variable cannot decide which identity the request is made as
335// or which auth flow (OAuth2 vs. PAT) it uses. job_token is unaffected, so
336// CI_JOB_TOKEN authentication keeps working under CI auto-login.
337func WithoutTokenFromEnvironment() FromConfigOption {
338 return func(o *fromConfigOptions) {
339 o.searchEnvForIdentity = false
340 }
343// WithoutAuthentication builds an unauthenticated client that still uses the
344// host's transport settings from config (proxy, CA, client certificate,
345// skip_tls_verify, API host, and custom headers). Tokens from config, the
346// keyring, and the environment are neither read nor sent, so a missing or
347// unreadable keyring entry does not fail the build.
348//
349// Use it where a missing token is expected, such as the OAuth2 flow in
350// `glab auth login`, which sets use_keyring before it stores a token, or
351// where only the host's transport is needed, such as the Docker credential
352// helper.
353func WithoutAuthentication() FromConfigOption {
354 return func(o *fromConfigOptions) {
355 o.withoutAuthentication = true
356 }
359// WithTransportCache makes the client share its connection pool with other
360// clients built with the same cache and the same transport settings.
361func WithTransportCache(cache *TransportCache) FromConfigOption {
362 return func(o *fromConfigOptions) {
363 o.transports = cache
364 }
367// NewClientFromConfig initializes the global api with the config data
368func NewClientFromConfig(repoHost string, cfg config.Config, isGraphQL bool, userAgent string, opts ...FromConfigOption) (*Client, error) {
369 fromCfg := fromConfigOptions{searchEnvForIdentity: true}
370 for _, opt := range opts {
371 opt(&fromCfg)
372 }
374 apiHost, _ := cfg.Get(repoHost, "api_host")
375 if apiHost == "" {
376 apiHost = repoHost
377 }
378 subfolder, _ := cfg.Get(repoHost, "subfolder")
380 apiProtocol, _ := cfg.Get(repoHost, "api_protocol")
381 if apiProtocol == "" {
382 apiProtocol = glinstance.DefaultProtocol
383 }
385 isOAuth2Cfg, isOAuth2Source, _ := cfg.GetWithSource(repoHost, "is_oauth2", fromCfg.searchEnvForIdentity)
387 var token, tokenSource, jobToken string
388 if !fromCfg.withoutAuthentication {
389 // token and job_token may be backed by the OS keyring. Surface read errors
390 // (locked keyring, denied access, unavailable backend) instead of silently
391 // treating them as an empty credential, which produces confusing downstream
392 // auth errors. A credential that is simply not stored returns "" with no
393 // error.
394 var err error
395 token, tokenSource, err = cfg.GetWithSource(repoHost, "token", fromCfg.searchEnvForIdentity)
396 if err != nil {
397 return nil, fmt.Errorf("failed to read the access token for %q: %w", repoHost, err)
398 }
399 jobToken, err = cfg.Get(repoHost, "job_token")
400 if err != nil {
401 return nil, fmt.Errorf("failed to read the job token for %q: %w", repoHost, err)
402 }
403 }
405 isOAuth2 := isOAuth2Cfg == "true"
406 isEnvironmentPAT := tokenSource == "GITLAB_TOKEN" || tokenSource == "GITLAB_ACCESS_TOKEN"
407 isEnvironmentOAuth2 := isOAuth2Source == "GLAB_IS_OAUTH2"
408 if isEnvironmentPAT && !isEnvironmentOAuth2 {
409 isOAuth2 = false
410 }
411 tlsVerify, _ := cfg.Get(repoHost, "skip_tls_verify")
412 skipTlsVerify := tlsVerify == "true" || tlsVerify == "1"
413 caCert, _ := cfg.Get(repoHost, "ca_cert")
414 clientCert, _ := cfg.Get(repoHost, "client_cert")
415 keyFile, _ := cfg.Get(repoHost, "client_key")
416 proxyURL, err := config.ResolveHostProxy(cfg, repoHost)
417 if err != nil {
418 return nil, fmt.Errorf("failed to resolve proxy: %w", err)
419 }
421 // Build options based on configuration
422 options := []ClientOption{
423 WithUserAgent(userAgent),
424 WithProxy(proxyURL),
425 func(c *Client) error {
426 c.transports = fromCfg.transports
427 return nil
428 },
429 }
431 headers, err := config.ResolveCustomHeaders(cfg, repoHost)
432 if err != nil {
433 return nil, fmt.Errorf("failed to resolve custom headers: %w", err)
434 }
436 // DUO_WORKFLOW_WORKFLOW_ID is an internal contract intentionally not in user-facing
437 // env-var docs. Set by GitLab's Workflow service so the API server can correlate
438 // CLI traffic back to the originating workflow. Takes precedence over the same
439 // header set via config. Read directly rather than via EnvKeyEquivalence because
440 // the value is per-process with no config-file equivalent. Skip the header entirely
441 // on malformed input (CR/LF/NUL).
442 if duoWorkflowID := os.Getenv("DUO_WORKFLOW_WORKFLOW_ID"); duoWorkflowID != "" && !strings.ContainsAny(duoWorkflowID, "\r\n\x00") {
443 if headers == nil {
444 headers = make(map[string]string)
445 }
446 headers["X-Gitlab-Duo-Workflow-Id"] = duoWorkflowID
447 }
449 if len(headers) > 0 {
450 // OAuth refresh uses repoHost even when API requests use a separately
451 // configured api_host, so allow both destinations.
452 options = append(options, WithCustomHeaders(headers, repoHost))
453 }
455 // determine auth source
456 var newAuthSource newAuthSource
457 switch {
458 case fromCfg.withoutAuthentication:
459 newAuthSource = func(*http.Client) (gitlab.AuthSource, error) {
460 return gitlab.Unauthenticated{}, nil
461 }
462 case isOAuth2:
463 // If the refresh token can't be read but a usable access token is still
464 // present, fall through to access-token-only auth rather than failing
465 // the whole client build. Log the read failure (surfaced with DEBUG) so
466 // it is not lost; a hard error still occurs at refresh time when renewal
467 // is actually attempted.
468 refreshToken, refreshErr := cfg.Get(repoHost, "oauth2_refresh_token")
469 if refreshErr != nil {
470 if token == "" {
471 return nil, fmt.Errorf("failed to read the OAuth2 refresh token for %q: %w", repoHost, refreshErr)
472 }
473 dbg.Debugf("failed to read oauth2_refresh_token for %q: %v", repoHost, refreshErr)
474 }
475 if refreshToken == "" {
476 if token == "" {
477 return nil, unauthenticatedError{fmt.Errorf("OAuth2 authentication is configured for %q but no access or refresh token was found (the stored credentials may be missing or incomplete); run `glab auth login --hostname %s` to re-authenticate", repoHost, repoHost)}
478 }
480 // The stored expiry belongs to the stored token, not one from the environment.
481 var expiry time.Time
482 if !slices.Contains(config.EnvKeyEquivalence("token"), tokenSource) {
483 expiry = storedOAuth2Expiry(cfg, repoHost)
484 }
486 newAuthSource = func(client *http.Client) (gitlab.AuthSource, error) {
487 return oauth2AccessTokenOnlyAuthSource{token: token, host: repoHost, expiry: expiry}, nil
488 }
489 break
490 }
492 newAuthSource = func(client *http.Client) (gitlab.AuthSource, error) {
493 ts, err := oauth2.NewConfigTokenSource(cfg, client, glinstance.DefaultProtocol, repoHost, fromCfg.searchEnvForIdentity)
494 if err != nil {
495 return nil, err
496 }
497 return gitlab.OAuthTokenSource{TokenSource: ts}, nil
498 }
499 case token != "":
500 // Check for PAT first since it's more common than job tokens
501 newAuthSource = func(*http.Client) (gitlab.AuthSource, error) {
502 return gitlab.AccessTokenAuthSource{Token: token}, nil
503 }
504 case jobToken != "":
505 newAuthSource = func(*http.Client) (gitlab.AuthSource, error) {
506 return gitlab.JobTokenAuthSource{Token: jobToken}, nil
507 }
508 default:
509 if config.HostUsesKeyring(cfg, repoHost) {
510 return nil, unauthenticatedError{fmt.Errorf("the token for %q is missing from the operating system keyring; run `glab auth login --hostname %s` to re-authenticate", repoHost, repoHost)}
511 }
513 // NOTE: use an unauthenticated client.
514 newAuthSource = func(*http.Client) (gitlab.AuthSource, error) {
515 return gitlab.Unauthenticated{}, nil
516 }
517 }
519 var baseURL string
520 if isGraphQL {
521 baseURL = glinstance.GraphQLEndpoint(repoHost, apiProtocol, apiHost, subfolder)
522 } else {
523 baseURL = glinstance.APIEndpoint(repoHost, apiProtocol, apiHost, subfolder)
524 }
525 options = append(options, WithBaseURL(baseURL))
527 if caCert != "" {
528 options = append(options, WithCustomCA(caCert))
529 }
531 if clientCert != "" {
532 clientCertPassword := func() (string, error) {
533 password, err := cfg.Get(repoHost, "client_cert_password")
534 if err != nil {
535 return "", fmt.Errorf("failed to read client_cert_password for %q: %w", repoHost, err)
536 }
537 return password, nil
538 }
539 options = append(options, WithClientCertificate(clientCert, keyFile, clientCertPassword))
540 }
542 if skipTlsVerify {
543 options = append(options, WithInsecureSkipVerify(skipTlsVerify))
544 }
546 return NewClient(newAuthSource, options...)
549func NewHTTPRequest(ctx context.Context, c *Client, method string, baseURL *url.URL, body io.Reader, headers []string, bodyIsJSON bool) (*http.Request, error) {
550 req, err := http.NewRequestWithContext(ctx, method, baseURL.String(), body)
551 if err != nil {
552 return nil, err
553 }
555 // Add any headers passed directly to this function
556 for _, h := range headers {
557 idx := strings.IndexRune(h, ':')
558 if idx == -1 {
559 return nil, fmt.Errorf("header %q requires a value separated by ':'", h)
560 }
561 name, value := h[0:idx], strings.TrimSpace(h[idx+1:])
562 if strings.EqualFold(name, "Content-Length") {
563 length, err := strconv.ParseInt(value, 10, 0)
564 if err != nil {
565 return nil, err
566 }
567 req.ContentLength = length
568 } else {
569 req.Header.Add(name, value)
570 }
571 }
573 if bodyIsJSON && req.Header.Get("Content-Type") == "" {
574 req.Header.Set("Content-Type", "application/json; charset=utf-8")
575 }
577 if c.Lab().UserAgent != "" {
578 req.Header.Set("User-Agent", c.Lab().UserAgent)
579 }
581 // gitlab.Unauthenticated's Header returns a sentinel error; the go-gitlab
582 // client's AllHeadersAuthStrategy skips the header in that case. Mirror
583 // that here so `glab api` works on public endpoints without auth.
584 if _, ok := c.authSource.(gitlab.Unauthenticated); !ok {
585 name, value, err := c.authSource.Header(ctx)
586 if err != nil {
587 return nil, err
588 }
589 req.Header.Set(name, value)
590 }
592 return req, nil
595// Is404 checks if the error represents a 404 response
596func Is404(err error) bool {
597 // If the error is a typed response
598 errResponse := &gitlab.ErrorResponse{}
599 if errors.As(err, &errResponse) &&
600 errResponse.Response != nil &&
601 errResponse.Response.StatusCode == http.StatusNotFound {
602 return true
603 }
605 // This can also come back as a string 404 from gitlab client-go
606 if err != nil && err.Error() == "404 Not Found" {
607 return true
608 }
610 return false
613// storedOAuth2Expiry reports the expiry recorded for the host, or the zero time
614// when there is nothing usable stored. There is no refresh token in this path,
615// so an unreadable date is not worth failing the client build over.
616func storedOAuth2Expiry(cfg config.Config, repoHost string) time.Time {
617 stored, err := cfg.Get(repoHost, "oauth2_expiry_date")
618 if err != nil || stored == "" {
619 dbg.Debugf("no usable oauth2_expiry_date for %q: %v", repoHost, err)
620 return time.Time{}
621 }
623 expiry, err := oauth2.ParseExpiryDate(stored)
624 if err != nil {
625 dbg.Debugf("could not parse oauth2_expiry_date for %q: %v", repoHost, err)
626 return time.Time{}
627 }
629 return expiry
Diagnostics6 git calls · 208 ms
CallStatusSizeTime0208 ms
discover200185 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=185
git.server.agent=git/2.56.g1891de4-Linux
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch server-option object-format
git.server.fetch=shallow wait-for-done filter
git.protocol.version=2
git.pkt.frames=9
git.pkt.data=7
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=185
git.pkt.payload.max=35
ls-refs20058 KiB · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=59849
git.response.cache=HIT
git.response.duration_ms=2
git.protocol.version=2
git.pkt.frames=731
git.pkt.data=730
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=59849
git.pkt.payload.max=143
git.ls_refs.count=730
git.ls_refs.head=refs/heads/main
fetchtree:0 · deepen 1020032 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=32926
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=tree:0
git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=22
git.pkt.data=20
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=32926
git.pkt.payload.max=32046
git.sideband.band1.bytes=32046
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=80
git.pack.bytes=32046
git.pack.ofs_delta=36
git.pack.ref_delta=0
git.pack.chain.max=2
git.pack.trailer=cb0bad5d7ffc514895d8b21c4dd470327f90bc91
git.pack.full=44
Open pack map
fetchcombine:blob:none+tree:2 · deepen 12004.2 KiB · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=4273
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=combine:blob:none+tree:2
git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9
git.fetch.haves.count=0
git.fetch.deepen=1
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=7
git.pkt.data=5
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=4273
git.pkt.payload.max=4173
git.sideband.band1.bytes=4173
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=11
git.pack.bytes=4173
git.fetch.wide.objects=11
git.fetch.wide.extra_bytes=3930
git.fetch.wide.blobs=0
fetchtree:02001.1 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=199
git.response.bytes=1165
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=tree:0
git.fetch.wants=71c8407e0ff0e0af10f6a041ae330f754b68e7eb
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=1165
git.pkt.payload.max=1138
git.sideband.band1.bytes=1138
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=1138
git.pack.trailer=61886367c69619d8db2b2cf2d7d24dca2016141c
Open pack map
fetch2006.3 KiB201 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=6482
git.response.cache=MISS
git.response.duration_ms=201
git.fetch.wants=0b04b7d358c496eaebee2a52c1842c5c19b5d082
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=6482
git.pkt.payload.max=6455
git.sideband.band1.bytes=6455
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://gitlab.com/gitlab-org/cli
Ref
refs/heads/main
Commit
0dd7574dce9e385c5c30540e6c15657adc6bdce9
cf-ray
a5e1300b9d85a9fe
Request
2fc11bfc…
Protocol
v2 · sha1
Agent
git/2.56.g1891de4-Linux
Filter
advertised
Fetch
shallow wait-for-done filter
Capabilities
agent ls-refs fetch server-option object-format