-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci_runner: conditionally set extension.partialClone based on filter
If the filter is empty, unset the config. If the filter is available, set the config to "origin" to indicate the remote is a promisor remote. https://github.com/git/git/blob/08bdfd453584e489d5a551aecbdcb77584e1b958/Documentation/config/extensions.adoc?plain=1#L37-L47
- Loading branch information
Showing
1 changed file
with
17 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1963,10 +1963,6 @@ func (ws *workspace) config(ctx context.Context) error { | |
{"user.email", "[email protected]"}, | ||
{"user.name", "BuildBuddy"}, | ||
{"advice.detachedHead", "false"}, | ||
// With the version of git that we have installed in the CI runner | ||
// image, --filter=blob:none requires the partialClone extension to be | ||
// enabled. | ||
{"extensions.partialClone", "true"}, | ||
// Disable this check for `git fetch` performance improvements | ||
{"fetch.showForcedUpdates", "false"}, | ||
// Disable automatic gc - it can interfere with running `rm -rf .git` in | ||
|
@@ -1981,6 +1977,23 @@ func (ws *workspace) config(ctx context.Context) error { | |
// displays a blocking popup dialog) | ||
cfg = append(cfg, []string{"credential.helper", ""}) | ||
} | ||
if len(*gitFetchFilters) > 0 { | ||
// With the version of git that we have installed in the CI runner | ||
// image, --filter=blob:none requires the partialClone extension to be | ||
// enabled. | ||
cfg = append(cfg, []string{"extensions.partialClone", "origin"}) | ||
} else { | ||
// TODO(sluongng): "--enset-all" is deprecated in newer versions of git. | ||
// Switch to "git config unset --all" when we upgrade the git version. | ||
if _, err := git(ctx, io.Discard, "config", "--unset-all", "extensions.partialClone"); err != nil { | ||
// Expect code 5 when config was not set. | ||
// From git-config(1) man page: | ||
// "you try to unset an option which does not exist (ret=5)," | ||
if err.Error() != "exit status 5" { | ||
return fmt.Errorf("faild to unset git config extensions.partialClone: %w", err) | ||
} | ||
} | ||
} | ||
|
||
writeCommandSummary(ws.log, "Configuring repository...") | ||
for _, kv := range cfg { | ||
|