Skip to content

Commit e4fb15a

Browse files
committed
feat: adjust thinpack logging and option definition
1 parent 2a22162 commit e4fb15a

File tree

4 files changed

+35
-22
lines changed

4 files changed

+35
-22
lines changed

git/git.go

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,28 +54,40 @@ func CloneRepo(ctx context.Context, logf func(string, ...any), opts CloneRepoOpt
5454
return false, fmt.Errorf("parse url %q: %w", opts.RepoURL, err)
5555
}
5656
logf("Parsed Git URL as %q", parsed.Redacted())
57-
if parsed.Hostname() == "dev.azure.com" || opts.ThinPack {
58-
// Azure DevOps requires capabilities multi_ack / multi_ack_detailed,
59-
// which are not fully implemented and by default are included in
60-
// transport.UnsupportedCapabilities.
61-
//
62-
// The initial clone operations require a full download of the repository,
63-
// and therefore those unsupported capabilities are not as crucial, so
64-
// by removing them from that list allows for the first clone to work
65-
// successfully.
66-
//
67-
// Additional fetches will yield issues, therefore work always from a clean
68-
// clone until those capabilities are fully supported.
69-
//
70-
// New commits and pushes against a remote worked without any issues.
71-
// See: https://github.com/go-git/go-git/issues/64
72-
//
73-
// This is knowingly not safe to call in parallel, but it seemed
74-
// like the least-janky place to add a super janky hack.
57+
58+
thinPack := true
59+
60+
if !opts.ThinPack {
61+
thinPack = false
62+
logf("ThinPack options is false, Marking thin-pack as unsupported")
63+
} else {
64+
if parsed.Hostname() == "dev.azure.com" {
65+
// Azure DevOps requires capabilities multi_ack / multi_ack_detailed,
66+
// which are not fully implemented and by default are included in
67+
// transport.UnsupportedCapabilities.
68+
//
69+
// The initial clone operations require a full download of the repository,
70+
// and therefore those unsupported capabilities are not as crucial, so
71+
// by removing them from that list allows for the first clone to work
72+
// successfully.
73+
//
74+
// Additional fetches will yield issues, therefore work always from a clean
75+
// clone until those capabilities are fully supported.
76+
//
77+
// New commits and pushes against a remote worked without any issues.
78+
// See: https://github.com/go-git/go-git/issues/64
79+
//
80+
// This is knowingly not safe to call in parallel, but it seemed
81+
// like the least-janky place to add a super janky hack.
82+
thinPack = false
83+
logf("Workaround for Azure DevOps: marking thin-pack as unsupported")
84+
}
85+
}
86+
87+
if !thinPack {
7588
transport.UnsupportedCapabilities = []capability.Capability{
7689
capability.ThinPack,
7790
}
78-
logf("Workaround for Azure DevOps: marking thin-pack as unsupported")
7991
}
8092

8193
err = opts.Storage.MkdirAll(opts.Path, 0o755)

options/options.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ func (o *Options) CLI() serpent.OptionSet {
381381
Flag: "git-clone-thinpack",
382382
Env: WithEnvPrefix("GIT_CLONE_THINPACK"),
383383
Value: serpent.BoolOf(&o.GitCloneThinPack),
384-
Description: "Clone with thin pack compabilities.",
384+
Default: "true",
385+
Description: "Git clone with thin pack compatibility enable.",
385386
},
386387
{
387388
Flag: "git-username",

options/options_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func TestEnvOptionParsing(t *testing.T) {
7070
t.Setenv(options.WithEnvPrefix("GIT_CLONE_THINPACK"), "")
7171
o := runCLI()
7272
require.False(t, o.GitCloneSingleBranch)
73-
require.False(t, o.GitCloneThinPack)
73+
require.True(t, o.GitCloneThinPack)
7474
})
7575
})
7676
}

options/testdata/options.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ OPTIONS:
100100
Clone only a single branch of the Git repository.
101101

102102
--git-clone-thinpack bool, $ENVBUILDER_GIT_CLONE_THINPACK
103-
Clone with thin pack compabilities.
103+
Git clone with thin pack compatibility enable.
104104

105105
--git-http-proxy-url string, $ENVBUILDER_GIT_HTTP_PROXY_URL
106106
The URL for the HTTP proxy. This is optional.

0 commit comments

Comments
 (0)