Skip to content

Commit

Permalink
Fix azure devops git clone error (#400)
Browse files Browse the repository at this point in the history
* fix git clone in azure devops

* Add unit tests

* Fix imports
  • Loading branch information
raulcabello committed Jan 8, 2024
1 parent 049ba46 commit 4d30c6a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/gitcloner/gogit/cloner.go
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/protocol/packp/capability"
"github.com/go-git/go-git/v5/plumbing/transport"
httpgit "github.com/go-git/go-git/v5/plumbing/transport/http"
gossh "github.com/go-git/go-git/v5/plumbing/transport/ssh"
Expand Down Expand Up @@ -37,6 +38,12 @@ func NewCloner() *Cloner {
}

func (c *Cloner) CloneRepo(opts *cmd.Options) error {
// Azure DevOps requires capabilities multi_ack / multi_ack_detailed,
// which are not fully implemented and by default are included in
// transport.UnsupportedCapabilities.
transport.UnsupportedCapabilities = []capability.Capability{
capability.ThinPack,
}
auth, err := createAuthFromOpts(opts)
if err != nil {
return err
Expand Down
7 changes: 7 additions & 0 deletions cmd/gitcloner/gogit/cloner_test.go
Expand Up @@ -5,6 +5,9 @@ import (
"os"
"testing"

"github.com/go-git/go-git/v5/plumbing/protocol/packp/capability"
"github.com/go-git/go-git/v5/plumbing/transport"

"github.com/go-git/go-git/v5"
httpgit "github.com/go-git/go-git/v5/plumbing/transport/http"
gossh "github.com/go-git/go-git/v5/plumbing/transport/ssh"
Expand Down Expand Up @@ -172,6 +175,10 @@ udiSlDctMM/X3ZM2JN5M1rtAJ2WR3ZQtmWbOjZAbG2Eq
if !cmp.Equal(cloneOptsCalled, test.expectedCloneOpts, sshKeyComparer) {
t.Fatalf("expected options %v, got %v", test.expectedCloneOpts, cloneOptsCalled)
}

if !cmp.Equal(transport.UnsupportedCapabilities, []capability.Capability{capability.ThinPack}) {
t.Errorf("expected transport.UnsupportedCapabilities []capability.Capability{capability.ThinPack}, got %v", transport.UnsupportedCapabilities)
}
})
}
}

0 comments on commit 4d30c6a

Please sign in to comment.