|
@ -15,6 +15,12 @@ interface PullRequestNode { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
interface PullRequest { |
|
|
interface PullRequest { |
|
|
|
|
|
readonly base: { |
|
|
|
|
|
readonly repositoryCloneUrl: { |
|
|
|
|
|
readonly owner: string; |
|
|
|
|
|
readonly repositoryName: string; |
|
|
|
|
|
}; |
|
|
|
|
|
}; |
|
|
readonly githubRepository: { |
|
|
readonly githubRepository: { |
|
|
readonly rootUri: Uri; |
|
|
readonly rootUri: Uri; |
|
|
}; |
|
|
}; |
|
@ -48,26 +54,26 @@ export class CreateWorktreeCommand extends Command { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const { |
|
|
const { |
|
|
|
|
|
base: { |
|
|
|
|
|
repositoryCloneUrl: { owner: rootOwner, repositoryName: rootRepository }, |
|
|
|
|
|
}, |
|
|
githubRepository: { rootUri }, |
|
|
githubRepository: { rootUri }, |
|
|
head: { |
|
|
head: { |
|
|
repositoryCloneUrl: { url: remoteUri, owner: remoteOwner }, |
|
|
repositoryCloneUrl: { url: remoteUri, owner: remoteOwner }, |
|
|
ref, |
|
|
ref, |
|
|
}, |
|
|
}, |
|
|
|
|
|
item: { number }, |
|
|
} = pr; |
|
|
} = pr; |
|
|
|
|
|
|
|
|
let repo = this.container.git.getRepository(rootUri); |
|
|
let repo = this.container.git.getRepository(rootUri); |
|
|
if (repo == null) { |
|
|
if (repo == null) { |
|
|
void window.showWarningMessage( |
|
|
|
|
|
`Unable to find repository(${rootUri.toString()}) for PR #${pr.item.number}`, |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
void window.showWarningMessage(`Unable to find repository(${rootUri.toString()}) for PR #${number}`); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
repo = await repo.getMainRepository(); |
|
|
repo = await repo.getMainRepository(); |
|
|
if (repo == null) { |
|
|
if (repo == null) { |
|
|
void window.showWarningMessage( |
|
|
|
|
|
`Unable to find main repository(${rootUri.toString()}) for PR #${pr.item.number}`, |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
void window.showWarningMessage(`Unable to find main repository(${rootUri.toString()}) for PR #${number}`); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -103,6 +109,17 @@ export class CreateWorktreeCommand extends Command { |
|
|
remote: true, |
|
|
remote: true, |
|
|
}), |
|
|
}), |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// Save the PR number in the branch config
|
|
|
|
|
|
const cfg = await this.container.git.getConfig(repo.path, `branch.${ref}.remote`); |
|
|
|
|
|
if (cfg != null) { |
|
|
|
|
|
// https://github.com/Microsoft/vscode-pull-request-github/blob/0c556c48c69a3df2f9cf9a45ed2c40909791b8ab/src/github/pullRequestGitHelper.ts#L18
|
|
|
|
|
|
void this.container.git.setConfig( |
|
|
|
|
|
repo.path, |
|
|
|
|
|
`branch.${ref}.github-pr-owner-number`, |
|
|
|
|
|
`${rootOwner}#${rootRepository}#${number}`, |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
} catch (ex) { |
|
|
} catch (ex) { |
|
|
Logger.error(ex, 'CreateWorktreeCommand', 'Unable to create worktree'); |
|
|
Logger.error(ex, 'CreateWorktreeCommand', 'Unable to create worktree'); |
|
|
void window.showErrorMessage(`Unable to create worktree for ${ref}`); |
|
|
void window.showErrorMessage(`Unable to create worktree for ${ref}`); |
|
|