Skip to content
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

Merged
merged 1 commit into from
May 13, 2022

Conversation

svenefftinge
Copy link
Member

@svenefftinge svenefftinge commented May 12, 2022

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 with git log).

NONE

@svenefftinge svenefftinge force-pushed the sefftinge/multi-repo-shallow-clones-9021 branch from 980bcab to 38e18ee Compare May 12, 2022 08:22
@roboquat roboquat added size/XL and removed size/M labels May 12, 2022
@svenefftinge svenefftinge force-pushed the sefftinge/multi-repo-shallow-clones-9021 branch from 38e18ee to 7ed1869 Compare May 12, 2022 09:19
@svenefftinge svenefftinge marked this pull request as ready for review May 12, 2022 09:35
@svenefftinge svenefftinge requested review from a team May 12, 2022 09:35
@github-actions github-actions bot added team: IDE team: workspace Issue belongs to the Workspace team labels May 12, 2022
@svenefftinge svenefftinge force-pushed the sefftinge/multi-repo-shallow-clones-9021 branch from 7ed1869 to 7455ba7 Compare May 12, 2022 14:16
Copy link
Member

@akosyakov akosyakov left a 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

Copy link
Contributor

@csweichel csweichel left a 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 {
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member Author

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{""}
Copy link
Contributor

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

Suggested change
return []string{""}
return nil

Comment on lines 554 to 556
for _, path := range GetCheckoutLocationsFromInitializer(c) {
result = append(result, path)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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) {
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: TODO comments

Suggested change
//TODO remove me after deployment (backward compatibility)
//TODO(sefftinge) remove me after deployment (backward compatibility)

@svenefftinge
Copy link
Member Author

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?

Yes, the reason is I couldn'T find a git initializer but only snapshot initializers. Maybe I missed something?

@svenefftinge svenefftinge force-pushed the sefftinge/multi-repo-shallow-clones-9021 branch 3 times, most recently from 8d98a4e to 7d98110 Compare May 13, 2022 05:12
fixes [multi-repo] Shallow clones are not inflated #9021
@svenefftinge svenefftinge force-pushed the sefftinge/multi-repo-shallow-clones-9021 branch from 7d98110 to 3574146 Compare May 13, 2022 06:51
@roboquat roboquat merged commit d8f51d3 into main May 13, 2022
@roboquat roboquat deleted the sefftinge/multi-repo-shallow-clones-9021 branch May 13, 2022 09:31
@roboquat roboquat added the deployed: IDE IDE change is running in production label May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: IDE IDE change is running in production release-note size/XL team: IDE team: workspace Issue belongs to the Workspace team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants