Skip to content

Commit

Permalink
the branch name is now optional, but still always defaults to 'main' …
Browse files Browse the repository at this point in the history
…for now
  • Loading branch information
balazsbajorics committed Jan 5, 2024
1 parent f3bb532 commit 81a87f9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ interface LoadFromGithubEvent {
workers: UtopiaTsWorkers
githubOwner: string
githubRepo: string
githubBranch: string
githubBranch: string | null
}

export function loadFromGithubEvent(
workers: UtopiaTsWorkers,
githubOwner: string,
githubRepo: string,
githubBranch: string,
githubBranch: string | null,
): LoadFromGithubEvent {
return {
type: 'LOAD_FROM_GITHUB',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface PersistenceContext<ModelType> {
githubRepo?: {
owner: string
repository: string
branch: string
branch: string | null
}
githubBranchContent?: BranchContent
}
Expand Down
2 changes: 1 addition & 1 deletion editor/src/components/editor/persistence/persistence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export class PersistenceMachine {
workers: UtopiaTsWorkers,
githubOwner: string,
githubRepo: string,
githubBranch: string,
githubBranch: string | null,
): void => {
this.interpreter.send(loadFromGithubEvent(workers, githubOwner, githubRepo, githubBranch))
}
Expand Down
14 changes: 11 additions & 3 deletions editor/src/core/shared/github/operations/load-branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,19 @@ export const cloneProjectFromGithubLoadAssetsAndRefreshDependencies =
workers: UtopiaTsWorkers,
onUpdate: (update: UpdateGithubOperations | AddToast) => void,
githubRepo: GithubRepo,
branchName: string,
branchName: string | null,
resetBranches: boolean,
): Promise<LoadFromGithubResult> => {
const resolvedBranchName: string = await (async () => {
if (branchName != null) {
return branchName
}
// TODO load the default branch name from the server
return 'main'
})()

const loadBranchResult = await loadBranchFromGithub(
branchName,
resolvedBranchName,
githubRepo,
onUpdate,
operationContext,
Expand All @@ -127,7 +135,7 @@ export const cloneProjectFromGithubLoadAssetsAndRefreshDependencies =
}

const parseDownloadedProjectResult = await parseDownloadedProject(
branchName,
resolvedBranchName,
githubRepo,
onUpdate,
loadBranchResult,
Expand Down
2 changes: 1 addition & 1 deletion editor/src/templates/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export class Editor {
this.storedState.workers,
githubOwner,
githubRepo,
githubBranch ?? 'main',
githubBranch, // if omitted, figure out the default branch!
)
} else if (importURL != null) {
this.createNewProjectFromImportURL(importURL)
Expand Down

0 comments on commit 81a87f9

Please sign in to comment.