Skip to content

Commit 0c84bd9

Browse files
authored
Merge pull request #50 from go-git/renovate/go-git
build: Update module github.com/go-git/go-git/v6 to v6.0.0-alpha.2
2 parents 4ad0196 + 4a5ff3f commit 0c84bd9

12 files changed

Lines changed: 73 additions & 53 deletions

File tree

cmd/gogit-http-server/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"path/filepath"
99

1010
"github.com/go-git/go-billy/v6/osfs"
11-
githttp "github.com/go-git/go-git/v6/backend/http"
11+
"github.com/go-git/go-git/v6/backend"
1212
"github.com/go-git/go-git/v6/plumbing/transport"
1313
"github.com/spf13/cobra"
1414
)
@@ -40,7 +40,7 @@ var rootCmd = &cobra.Command{
4040

4141
logger := log.Default()
4242
loader := transport.NewFilesystemLoader(osfs.New(abs, osfs.WithBoundOS()), false)
43-
gitmw := githttp.NewBackend(loader)
43+
gitmw := backend.New(loader)
4444

4545
handler := LoggingMiddleware(logger, gitmw)
4646

cmd/gogit/clone.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package main
22

33
import (
44
"fmt"
5+
"net/url"
56
"path"
67
"strings"
78

89
"github.com/go-git/go-git/v6"
9-
"github.com/go-git/go-git/v6/plumbing/transport"
1010
"github.com/spf13/cobra"
1111
)
1212

@@ -41,16 +41,16 @@ var cloneCmd = &cobra.Command{
4141
}
4242
}
4343

44-
ep, err := transport.NewEndpoint(args[0])
44+
ep, err := url.Parse(args[0])
4545
if err != nil {
4646
return err
4747
}
4848

4949
opts := git.CloneOptions{
50-
URL: args[0],
51-
Depth: cloneDepth,
52-
Auth: defaultAuth(ep),
53-
Bare: cloneBare,
50+
URL: args[0],
51+
Depth: cloneDepth,
52+
ClientOptions: defaultClientOptions(ep),
53+
Bare: cloneBare,
5454
}
5555

5656
if cloneTags {

cmd/gogit/daemon.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ package main
33
import (
44
"log"
55
"net"
6+
"net/url"
67
"path/filepath"
78
"strconv"
89

910
gitserver "github.com/go-git/cli/server/git"
1011
"github.com/go-git/go-billy/v6"
1112
"github.com/go-git/go-billy/v6/osfs"
12-
gitbackend "github.com/go-git/go-git/v6/backend/git"
1313
"github.com/go-git/go-git/v6/plumbing/transport"
1414
"github.com/go-git/go-git/v6/storage"
1515
"github.com/spf13/cobra"
@@ -40,7 +40,7 @@ var daemonCmd = &cobra.Command{
4040

4141
loader := NewDirsLoader(dirs, false, daemonExportAll)
4242
addr := net.JoinHostPort(daemonListen, strconv.Itoa(daemonPort))
43-
be := gitbackend.NewBackend(loader)
43+
be := gitserver.NewBackend(loader)
4444
srv := &gitserver.Server{
4545
Addr: addr,
4646
Handler: gitserver.LoggingMiddleware(log.Default(), be),
@@ -81,16 +81,16 @@ func NewDirsLoader(dirs []string, strict, exportAll bool) *dirsLoader {
8181
}
8282

8383
// Load implements transport.Loader.
84-
func (d *dirsLoader) Load(ep *transport.Endpoint) (storage.Storer, error) {
84+
func (d *dirsLoader) Load(u *url.URL) (storage.Storer, error) {
8585
for i, loader := range d.loaders {
86-
storer, err := loader.Load(ep)
86+
storer, err := loader.Load(u)
8787
if err == nil {
8888
if !d.exportAll {
8989
// We need to check if git-daemon-export-ok
9090
// file exists and if it does not, we skip this
9191
// repository.
9292
dfs := d.fss[i]
93-
okFile := filepath.Join(ep.Path, "git-daemon-export-ok")
93+
okFile := filepath.Join(u.Path, "git-daemon-export-ok")
9494

9595
stat, err := dfs.Lstat(okFile)
9696
if err != nil || (stat != nil && !stat.Mode().IsRegular()) {

cmd/gogit/fetch.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package main
33
import (
44
"errors"
55
"math"
6+
"net/url"
67

78
"github.com/go-git/go-git/v6"
8-
"github.com/go-git/go-git/v6/plumbing/transport"
99
"github.com/spf13/cobra"
1010
)
1111

@@ -38,7 +38,7 @@ var fetchCmd = &cobra.Command{
3838
return err
3939
}
4040

41-
ep, err := transport.NewEndpoint(remote.Config().URLs[0])
41+
ep, err := url.Parse(remote.Config().URLs[0])
4242
if err != nil {
4343
return err
4444
}
@@ -48,8 +48,8 @@ var fetchCmd = &cobra.Command{
4848
}
4949

5050
opts := git.FetchOptions{
51-
Depth: fetchDepth,
52-
Auth: defaultAuth(ep),
51+
Depth: fetchDepth,
52+
ClientOptions: defaultClientOptions(ep),
5353
}
5454

5555
if fetchProgress {

cmd/gogit/main.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ package main
33
import (
44
"errors"
55
"fmt"
6+
"net/url"
67
"os"
78
"strconv"
89

10+
"github.com/go-git/go-git/v6/plumbing/client"
911
"github.com/go-git/go-git/v6/plumbing/transport"
1012
"github.com/go-git/go-git/v6/plumbing/transport/ssh"
1113
"github.com/go-git/go-git/v6/utils/trace"
@@ -58,27 +60,31 @@ func main() {
5860
}
5961
}
6062

61-
func defaultAuth(ep *transport.Endpoint) transport.AuthMethod {
62-
switch ep.Scheme {
63+
func defaultClientOptions(u *url.URL) []client.Option {
64+
if u == nil {
65+
return nil
66+
}
67+
68+
switch u.Scheme {
6369
case "file", "git":
6470
// Do nothing.
6571
case "ssh":
66-
if ep.User == nil {
72+
if u.User == nil {
6773
return nil
6874
}
6975

70-
a, err := ssh.NewSSHAgentAuth(ep.User.Username())
76+
a, err := ssh.NewSSHAgentAuth(u.User.Username())
7177
if err != nil {
7278
return nil
7379
}
7480

75-
switch ep.Host {
81+
switch u.Host {
7682
case "localhost", "127.0.0.1":
7783
// Ignore host key verification for localhost.
7884
a.HostKeyCallback = gossh.InsecureIgnoreHostKey()
7985
}
8086

81-
return a
87+
return []client.Option{client.WithSSHAuth(a)}
8288
case "http", "https":
8389
}
8490

cmd/gogit/pull.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package main
22

33
import (
44
"errors"
5+
"net/url"
56

67
"github.com/go-git/go-git/v6"
7-
"github.com/go-git/go-git/v6/plumbing/transport"
88
"github.com/spf13/cobra"
99
)
1010

@@ -34,13 +34,13 @@ var pullCmd = &cobra.Command{
3434
return err
3535
}
3636

37-
ep, err := transport.NewEndpoint(cfg.Remotes["origin"].URLs[0])
37+
ep, err := url.Parse(cfg.Remotes["origin"].URLs[0])
3838
if err != nil {
3939
return err
4040
}
4141

4242
opts := git.PullOptions{
43-
Auth: defaultAuth(ep),
43+
ClientOptions: defaultClientOptions(ep),
4444
}
4545
if pullProgress {
4646
opts.Progress = cmd.OutOrStdout()

cmd/gogit/push.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package main
33
import (
44
"errors"
55
"fmt"
6+
"net/url"
67

78
"github.com/go-git/go-git/v6"
89
"github.com/go-git/go-git/v6/config"
910
"github.com/go-git/go-git/v6/plumbing"
10-
"github.com/go-git/go-git/v6/plumbing/transport"
1111
"github.com/spf13/cobra"
1212
"golang.org/x/term"
1313
)
@@ -43,7 +43,7 @@ var pushCmd = &cobra.Command{
4343
return fmt.Errorf("failed to get repository config: %w", err)
4444
}
4545

46-
var ep *transport.Endpoint
46+
var ep *url.URL
4747

4848
remoteName := git.DefaultRemoteName
4949

@@ -61,7 +61,7 @@ var pushCmd = &cobra.Command{
6161

6262
if !isRemote {
6363
// Is this a repository URL?
64-
ep, err = transport.NewEndpoint(args[0])
64+
ep, err = url.Parse(args[0])
6565
if err != nil {
6666
// We have a remote name
6767
remoteName = args[0]
@@ -91,18 +91,18 @@ var pushCmd = &cobra.Command{
9191
return errors.New("no remote URLs")
9292
}
9393

94-
ep, err = transport.NewEndpoint(remote.Config().URLs[urln])
94+
ep, err = url.Parse(remote.Config().URLs[urln])
9595
if err != nil {
9696
return err
9797
}
9898
}
9999

100100
opts := git.PushOptions{
101-
Auth: defaultAuth(ep),
102-
RemoteName: remoteName,
103-
RefSpecs: refspecs,
104-
Prune: pushPrune,
105-
Force: pushForce,
101+
ClientOptions: defaultClientOptions(ep),
102+
RemoteName: remoteName,
103+
RefSpecs: refspecs,
104+
Prune: pushPrune,
105+
Force: pushForce,
106106
}
107107

108108
var isatty bool

cmd/gogit/receive-pack.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var receivePackCmd = &cobra.Command{
3535
r.Storer,
3636
os.Stdin,
3737
os.Stdout,
38-
&transport.ReceivePackOptions{
38+
&transport.ReceivePackRequest{
3939
GitProtocol: os.Getenv("GIT_PROTOCOL"),
4040
StatelessRPC: receivePackStatelessRPC,
4141
AdvertiseRefs: receivePackAdvertiseRefs,

cmd/gogit/upload-pack.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var uploadPackCmd = &cobra.Command{
4848
r.Storer,
4949
os.Stdin,
5050
os.Stdout,
51-
&transport.UploadPackOptions{
51+
&transport.UploadPackRequest{
5252
GitProtocol: os.Getenv("GIT_PROTOCOL"),
5353
StatelessRPC: uploadPackStatelessRPC,
5454
AdvertiseRefs: uploadPackAdvertiseRefs,

go.mod

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ toolchain go1.25.4
77
require (
88
github.com/go-git/go-billy/v6 v6.0.0-20260410103409-85b6241850b5
99
github.com/go-git/go-git-fixtures/v6 v6.0.0-20260410103352-fe4fd2baf1dc
10-
github.com/go-git/go-git/v6 v6.0.0-alpha.1
10+
github.com/go-git/go-git/v6 v6.0.0-alpha.2
1111
github.com/spf13/cobra v1.10.2
1212
golang.org/x/crypto v0.50.0
1313
golang.org/x/term v0.42.0
@@ -20,14 +20,13 @@ require (
2020
github.com/cyphar/filepath-securejoin v0.6.1 // indirect
2121
github.com/emirpasic/gods v1.18.1 // indirect
2222
github.com/go-git/gcfg/v2 v2.0.2 // indirect
23-
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
2423
github.com/inconshreveable/mousetrap v1.1.0 // indirect
2524
github.com/kevinburke/ssh_config v1.6.0 // indirect
2625
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
2726
github.com/pjbgf/sha1cd v0.5.0 // indirect
2827
github.com/sergi/go-diff v1.4.0 // indirect
2928
github.com/spf13/pflag v1.0.9 // indirect
30-
golang.org/x/net v0.52.0 // indirect
31-
golang.org/x/sync v0.19.0 // indirect
29+
golang.org/x/net v0.53.0 // indirect
30+
golang.org/x/sync v0.20.0 // indirect
3231
golang.org/x/sys v0.43.0 // indirect
3332
)

0 commit comments

Comments
 (0)