# gitproto: extract transport interface and rename HTTPConn

`4961145`→[main](/content/gh/entireio/git-sync/commits/main/index.html)·

Soph·2mo ago·18 files·+178 added/-137 removed

## Sessions

f97b592d8e72View transcript

## Changes

18

- internal

- gitproto

- Aconn.go+18

- Mfetch.go+11/-11

- Mfetch_test.go+14/-14

- Mpush.go+8/-8

- Mpush_test.go+4/-4

- Mrefs.go+4/-4

- Msmarthttp.go+44/-25

- Msmarthttp_test.go+20/-20

- strategy

- bootstrap

- Mbootstrap.go+13/-9

- Mbootstrap_test.go+18/-18

- incremental

- Mincremental.go+2/-2

- Mincremental_test.go+6/-6

- materialized

- Mmaterialized.go+2/-2

- replicate

- Mreplicate.go+2/-2

- Mreplicate_test.go+3/-3

- syncer

- Mauth_test.go+2/-2

- Msyncer.go+6/-6

- Msyncer_test.go+1/-1

```go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

package gitproto

import (
	"context"
	"io"
	"net/url"
)

// Conn represents a connection to a Git remote transport such as Smart HTTP
// or SSH.
type Conn interface {
	RequestInfoRefs(ctx context.Context, service string, gitProtocol string) ([]byte, error)
	PostRPCStreamBody(ctx context.Context, service string, body io.Reader, v2 bool, phase string) (io.ReadCloser, error)
	Endpoint() *url.URL
	ProgressWriter() io.Writer
	SetProgressWriter(w io.Writer)
	Close() error
}
```

Minternal/gitproto/conn.go+18

```go
// Caller must close the returned ReadCloser.
func (s *RefService) FetchToStore(
	ctx context.Context,
	store storer.Storer,
	conn *Conn,
	conn Conn,
	desired map[plumbing.ReferenceName]DesiredRef,
	targetRefs map[plumbing.ReferenceName]plumbing.Hash,
) error {
// Caller must close the returned ReadCloser.
func (s *RefService) FetchPack(
	ctx context.Context,
	conn *Conn,
	conn Conn,
	desired map[plumbing.ReferenceName]DesiredRef,
	targetRefs map[plumbing.ReferenceName]plumbing.Hash,
) (io.ReadCloser, error) {
// Caller must close the returned ReadCloser.
func (s *RefService) FetchCommitGraph(
	ctx context.Context,
	store storer.Storer,
	conn *Conn,
	conn Conn,
	ref DesiredRef,
	haves []plumbing.Hash,
) error {
// Caller must close the returned ReadCloser.
func (s *RefService) FetchPack(
	ctx context.Context,
	conn *Conn,
	conn Conn,
	desired map[plumbing.ReferenceName]DesiredRef,
	targetRefs map[plumbing.ReferenceName]plumbing.Hash,
) (io.ReadCloser, error) {
```
