Skip to content

Support for multi-repo projects #7785

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

Merged
merged 2 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/content-service-api/go/blobs_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/content-service-api/go/content_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/content-service-api/go/ideplugin_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions components/content-service-api/go/initializer.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/content-service-api/go/workspace_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions components/content-service-api/initializer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ message SnapshotInitializer {
}

// A prebuild initializer combines snapshots with Git: first we try the snapshot, then apply the Git clone target.
// If restoring the snapshot fails, we fall back to a regular Git initializer.
// If restoring the snapshot fails, we fall back to a regular Git initializer, which might be composite git initializer for multi-repo projects.
message PrebuildInitializer {
SnapshotInitializer prebuild = 1;
GitInitializer git = 2;
repeated GitInitializer git = 2;
}

// FromBackupInitializer initializes content from a previously made backup
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down Expand Up @@ -275,11 +275,10 @@ export class PrebuildInitializer extends jspb.Message {
clearPrebuild(): void;
getPrebuild(): SnapshotInitializer | undefined;
setPrebuild(value?: SnapshotInitializer): PrebuildInitializer;

hasGit(): boolean;
clearGit(): void;
getGit(): GitInitializer | undefined;
setGit(value?: GitInitializer): PrebuildInitializer;
clearGitList(): void;
getGitList(): Array<GitInitializer>;
setGitList(value: Array<GitInitializer>): PrebuildInitializer;
addGit(value?: GitInitializer, index?: number): GitInitializer;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): PrebuildInitializer.AsObject;
Expand All @@ -294,7 +293,7 @@ export class PrebuildInitializer extends jspb.Message {
export namespace PrebuildInitializer {
export type AsObject = {
prebuild?: SnapshotInitializer.AsObject,
git?: GitInitializer.AsObject,
gitList: Array<GitInitializer.AsObject>,
}
}

Expand Down
55 changes: 32 additions & 23 deletions components/content-service-api/typescript/src/initializer_pb.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down Expand Up @@ -220,7 +220,7 @@ if (goog.DEBUG && !COMPILED) {
* @constructor
*/
proto.contentservice.PrebuildInitializer = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
jspb.Message.initialize(this, opt_data, 0, -1, proto.contentservice.PrebuildInitializer.repeatedFields_, null);
};
goog.inherits(proto.contentservice.PrebuildInitializer, jspb.Message);
if (goog.DEBUG && !COMPILED) {
Expand Down Expand Up @@ -2086,6 +2086,13 @@ proto.contentservice.SnapshotInitializer.prototype.setSnapshot = function(value)



/**
* List of repeated fields within this message type.
* @private {!Array<number>}
* @const
*/
proto.contentservice.PrebuildInitializer.repeatedFields_ = [2];



if (jspb.Message.GENERATE_TO_OBJECT) {
Expand Down Expand Up @@ -2118,7 +2125,8 @@ proto.contentservice.PrebuildInitializer.prototype.toObject = function(opt_inclu
proto.contentservice.PrebuildInitializer.toObject = function(includeInstance, msg) {
var f, obj = {
prebuild: (f = msg.getPrebuild()) && proto.contentservice.SnapshotInitializer.toObject(includeInstance, f),
git: (f = msg.getGit()) && proto.contentservice.GitInitializer.toObject(includeInstance, f)
gitList: jspb.Message.toObjectList(msg.getGitList(),
proto.contentservice.GitInitializer.toObject, includeInstance)
};

if (includeInstance) {
Expand Down Expand Up @@ -2163,7 +2171,7 @@ proto.contentservice.PrebuildInitializer.deserializeBinaryFromReader = function(
case 2:
var value = new proto.contentservice.GitInitializer;
reader.readMessage(value,proto.contentservice.GitInitializer.deserializeBinaryFromReader);
msg.setGit(value);
msg.addGit(value);
break;
default:
reader.skipField();
Expand Down Expand Up @@ -2202,9 +2210,9 @@ proto.contentservice.PrebuildInitializer.serializeBinaryToWriter = function(mess
proto.contentservice.SnapshotInitializer.serializeBinaryToWriter
);
}
f = message.getGit();
if (f != null) {
writer.writeMessage(
f = message.getGitList();
if (f.length > 0) {
writer.writeRepeatedMessage(
2,
f,
proto.contentservice.GitInitializer.serializeBinaryToWriter
Expand Down Expand Up @@ -2251,39 +2259,40 @@ proto.contentservice.PrebuildInitializer.prototype.hasPrebuild = function() {


/**
* optional GitInitializer git = 2;
* @return {?proto.contentservice.GitInitializer}
* repeated GitInitializer git = 2;
* @return {!Array<!proto.contentservice.GitInitializer>}
*/
proto.contentservice.PrebuildInitializer.prototype.getGit = function() {
return /** @type{?proto.contentservice.GitInitializer} */ (
jspb.Message.getWrapperField(this, proto.contentservice.GitInitializer, 2));
proto.contentservice.PrebuildInitializer.prototype.getGitList = function() {
return /** @type{!Array<!proto.contentservice.GitInitializer>} */ (
jspb.Message.getRepeatedWrapperField(this, proto.contentservice.GitInitializer, 2));
};


/**
* @param {?proto.contentservice.GitInitializer|undefined} value
* @param {!Array<!proto.contentservice.GitInitializer>} value
* @return {!proto.contentservice.PrebuildInitializer} returns this
*/
proto.contentservice.PrebuildInitializer.prototype.setGit = function(value) {
return jspb.Message.setWrapperField(this, 2, value);
proto.contentservice.PrebuildInitializer.prototype.setGitList = function(value) {
return jspb.Message.setRepeatedWrapperField(this, 2, value);
};


/**
* Clears the message field making it undefined.
* @return {!proto.contentservice.PrebuildInitializer} returns this
* @param {!proto.contentservice.GitInitializer=} opt_value
* @param {number=} opt_index
* @return {!proto.contentservice.GitInitializer}
*/
proto.contentservice.PrebuildInitializer.prototype.clearGit = function() {
return this.setGit(undefined);
proto.contentservice.PrebuildInitializer.prototype.addGit = function(opt_value, opt_index) {
return jspb.Message.addToRepeatedWrapperField(this, 2, opt_value, proto.contentservice.GitInitializer, opt_index);
};


/**
* Returns whether this field is set.
* @return {boolean}
* Clears the list making it empty but non-null.
* @return {!proto.contentservice.PrebuildInitializer} returns this
*/
proto.contentservice.PrebuildInitializer.prototype.hasGit = function() {
return jspb.Message.getField(this, 2) != null;
proto.contentservice.PrebuildInitializer.prototype.clearGitList = function() {
return this.setGitList([]);
};


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
Expand Down
3 changes: 2 additions & 1 deletion components/content-service/pkg/initializer/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ func (ws *GitInitializer) realizeCloneTarget(ctx context.Context) (err error) {
if ws.TargetMode == RemoteBranch {
// create local branch based on specific remote branch
if err := ws.Git(ctx, "checkout", "-B", ws.CloneTarget, "origin/"+ws.CloneTarget); err != nil {
return err
log.WithField("remoteURI", ws.RemoteURI).WithField("branch", ws.CloneTarget).Debug("Remote branch doesn't exist.")
return nil
}
} else if ws.TargetMode == LocalBranch {
// checkout local branch based on remote HEAD
Expand Down
19 changes: 9 additions & 10 deletions components/content-service/pkg/initializer/initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,24 @@ func NewFromRequest(ctx context.Context, loc string, rs storage.DirectDownloader
if ir.Prebuild == nil {
return nil, status.Error(codes.InvalidArgument, "missing prebuild initializer spec")
}
if ir.Prebuild.Git == nil {
return nil, status.Error(codes.InvalidArgument, "missing prebuild Git initializer spec")
}

gitinit, err := newGitInitializer(ctx, loc, ir.Prebuild.Git, opts.ForceGitpodUserForGit)
if err != nil {
return nil, err
}
var snapshot *SnapshotInitializer
if ir.Prebuild.Prebuild != nil {
snapshot, err = newSnapshotInitializer(loc, rs, ir.Prebuild.Prebuild)
if err != nil {
return nil, status.Error(codes.Internal, fmt.Sprintf("cannot setup prebuild init: %v", err))
}
}

var gits []*GitInitializer
for _, gi := range ir.Prebuild.Git {
gitinit, err := newGitInitializer(ctx, loc, gi, opts.ForceGitpodUserForGit)
if err != nil {
return nil, err
}
gits = append(gits, gitinit)
}
initializer = &PrebuildInitializer{
Git: gitinit,
Prebuild: snapshot,
Git: gits,
}
} else if ir, ok := spec.(*csapi.WorkspaceInitializer_Snapshot); ok {
initializer, err = newSnapshotInitializer(loc, rs, ir.Snapshot)
Expand Down
Loading