-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[prebuild] Support opening a specfic prebuild #13706
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Copyright (c) 2021 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. | ||
*/ | ||
|
||
import { User, WorkspaceContext } from "@gitpod/gitpod-protocol"; | ||
import { log } from "@gitpod/gitpod-protocol/lib/util/logging"; | ||
import { OpenPrebuildContext } from "@gitpod/gitpod-protocol/src/protocol"; | ||
import { inject, injectable } from "inversify"; | ||
import { Config } from "../config"; | ||
import { IPrefixContextParser } from "./context-parser"; | ||
|
||
@injectable() | ||
export class OpenPrebuildPrefixContextParser implements IPrefixContextParser { | ||
@inject(Config) protected readonly config: Config; | ||
static PREFIX = /^\/?open-prebuild\/([^\/]*)\//; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow, many thanks @csweichel for implementing a new context URL prefix for this! However, I'm curious why a new prefix is more beneficial than "just" pointing a Prebuild view's "New Workspace" button to the (already-supported) fully-qualified commit context URL -- if you open the exact commit that was used to create the prebuild, you're guaranteed to get this prebuild, right? 💭 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Aye. Two reasons not to build it this way:
Another question would be: why use a prefix context parser rather than a regular context parser. This also has a couple of reasons:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Makes sense. (I guess to achieve the commit context URL trick, we'd need to always store the commit's treeURL in our metadata. But I'm happy to go with your approach that identifies prebuilds directly. 👍) |
||
|
||
findPrefix(user: User, context: string): string | undefined { | ||
const result = OpenPrebuildPrefixContextParser.PREFIX.exec(context); | ||
if (!result) { | ||
return undefined; | ||
} | ||
return result[0]; | ||
} | ||
|
||
public async handle(user: User, prefix: string, context: WorkspaceContext): Promise<WorkspaceContext> { | ||
const match = OpenPrebuildPrefixContextParser.PREFIX.exec(prefix); | ||
if (!match) { | ||
log.error("Could not parse prefix " + prefix); | ||
return context; | ||
} | ||
|
||
(context as OpenPrebuildContext).openPrebuilID = match[1]; | ||
return context; | ||
} | ||
} |
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.
I guess the
(branch)
part of the button label no longer makes sense when we're opening the prebuild.Maybe let's remove it?
Or clarify it?