Skip to content

Commit d20129d

Browse files
authored
fix: rewrite clone capabilities for Azure DevOps (#109)
1 parent e75f22a commit d20129d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

git.go

+24
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/go-git/go-git/v5"
1111
"github.com/go-git/go-git/v5/plumbing"
1212
"github.com/go-git/go-git/v5/plumbing/cache"
13+
"github.com/go-git/go-git/v5/plumbing/protocol/packp/capability"
1314
"github.com/go-git/go-git/v5/plumbing/protocol/packp/sideband"
1415
"github.com/go-git/go-git/v5/plumbing/transport"
1516
"github.com/go-git/go-git/v5/storage/filesystem"
@@ -39,6 +40,29 @@ func CloneRepo(ctx context.Context, opts CloneRepoOptions) (bool, error) {
3940
if err != nil {
4041
return false, fmt.Errorf("parse url %q: %w", opts.RepoURL, err)
4142
}
43+
if parsed.Hostname() == "dev.azure.com" {
44+
// Azure DevOps requires capabilities multi_ack / multi_ack_detailed,
45+
// which are not fully implemented and by default are included in
46+
// transport.UnsupportedCapabilities.
47+
//
48+
// The initial clone operations require a full download of the repository,
49+
// and therefore those unsupported capabilities are not as crucial, so
50+
// by removing them from that list allows for the first clone to work
51+
// successfully.
52+
//
53+
// Additional fetches will yield issues, therefore work always from a clean
54+
// clone until those capabilities are fully supported.
55+
//
56+
// New commits and pushes against a remote worked without any issues.
57+
// See: https://github.com/go-git/go-git/issues/64
58+
//
59+
// This is knowingly not safe to call in parallel, but it seemed
60+
// like the least-janky place to add a super janky hack.
61+
transport.UnsupportedCapabilities = []capability.Capability{
62+
capability.ThinPack,
63+
}
64+
}
65+
4266
err = opts.Storage.MkdirAll(opts.Path, 0755)
4367
if err != nil {
4468
return false, fmt.Errorf("mkdir %q: %w", opts.Path, err)

0 commit comments

Comments
 (0)