-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[supervisor] inflate all git repos #9961
Conversation
980bcab
to
38e18ee
Compare
38e18ee
to
7ed1869
Compare
7ed1869
to
7455ba7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm and works as advertised
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change makes a ton of sense.
Got a few comments.
Also, I didn't see a CDWP fixture which actually has multiple roots. Is that because we don't have a CDWP fixture with a composite initializer, or is there something that's broken?
@@ -535,3 +535,27 @@ func GetCheckoutLocationFromInitializer(init *csapi.WorkspaceInitializer) string | |||
} | |||
return "" | |||
} | |||
|
|||
func GetCheckoutLocationsFromInitializer(init *csapi.WorkspaceInitializer) []string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this function replace GetCheckoutLocationFromInitializer
as in
var (
repoRoot string
roots = GetCheckoutLocationsFromInitializer(init)
)
if len(roots) > 0 {
repoRoot = roots[0]
}
?
If so, I'd vote for removing GetCheckoutLocationFromInitializer
in favour of this new function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The single (main) repo_root is unfortunately used in a few other places, so I opted at adding a second variant. So we can slowly migrate based on need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I understand now. 👍
} | ||
return result | ||
} | ||
return []string{""} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should return an empty list instead
return []string{""} | |
return nil |
for _, path := range GetCheckoutLocationsFromInitializer(c) { | ||
result = append(result, path) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for _, path := range GetCheckoutLocationsFromInitializer(c) { | |
result = append(result, path) | |
} | |
result = append(result, GetCheckoutLocationsFromInitializer(c)...) |
@@ -29,6 +30,64 @@ func (f *RecordingInitializer) Run(ctx context.Context, mappings []archive.IDMap | |||
return csapi.WorkspaceInitFromOther, nil | |||
} | |||
|
|||
func TestGetCheckoutLocationsFromInitializer(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be a table driven test:
import "github.com/google/go-cmp/cmp"
type Expectation struct {
Roots []string
}
tests := []struct{
Name string
Initializer *csapi.WorkspaceInitializer
}{
{
Name: "single git initializer",
Initializer: ...
}
}
for _, test := range tests {
t.Run(test.Name, func(t *testing.T) {
var act Expectation
act.Roots = initializer.GetCheckoutLocationsFromInitializer(test.Initializer)
if diff := cmp.Diff(test.Expectation, act); diff != "" {
t.Errorf("unexpected result (-want +got):\n%s", diff)
}
})
}
@@ -460,6 +464,10 @@ func loadWorkspaceConfigFromEnv() (*WorkspaceConfig, error) { | |||
if err != nil { | |||
return nil, xerrors.Errorf("cannot load workspace config: %w", err) | |||
} | |||
//TODO remove me after deployment (backward compatibility) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: TODO comments
//TODO remove me after deployment (backward compatibility) | |
//TODO(sefftinge) remove me after deployment (backward compatibility) |
Yes, the reason is I couldn'T find a git initializer but only snapshot initializers. Maybe I missed something? |
8d98a4e
to
7d98110
Compare
fixes [multi-repo] Shallow clones are not inflated #9021
7d98110
to
3574146
Compare
fixes [multi-repo] Shallow clones are not inflated #9021
How to test
start a workspace on a multi-repo. E.g. https://sefftinge-362778b072.preview.gitpod-dev.com/#https://github.com/svenefftinge/multi-repo-main
And verify that the environment variable
GITPOD_REPO_ROOTS
contains all three locations (comma separated) and all repositories are fully cloned (check withgit log
).