Browse Source

Adds modal to ask user to add remote

main
Eric Amodio 1 year ago
parent
commit
1f50ecab46
2 changed files with 16 additions and 2 deletions
  1. +9
    -1
      src/commands/ghpr/createWorktree.ts
  2. +7
    -1
      src/commands/gitCommands.actions.ts

+ 9
- 1
src/commands/ghpr/createWorktree.ts View File

@ -76,7 +76,15 @@ export class CreateWorktreeCommand extends Command {
let remote: GitRemote | undefined;
[remote] = await repo.getRemotes({ filter: r => r.url === remoteUrl });
if (remote == null) {
await GitActions.Remote.add(repo, remoteOwner, remoteUrl, { fetch: true });
const result = await window.showInformationMessage(
`Unable to find a remote for '${remoteUrl}'. Would you like to add a new remote?`,
{ modal: true },
{ title: 'Yes' },
{ title: 'No', isCloseAffordance: true },
);
if (result?.title !== 'Yes') return;
await GitActions.Remote.add(repo, remoteOwner, remoteUrl, { confirm: false, fetch: true });
[remote] = await repo.getRemotes({ filter: r => r.url === remoteUrl });
if (remote == null) return;
} else {

+ 7
- 1
src/commands/gitCommands.actions.ts View File

@ -822,9 +822,15 @@ export namespace GitActions {
}
export namespace Remote {
export function add(repo?: string | Repository, name?: string, url?: string, options?: { fetch?: boolean }) {
export function add(
repo?: string | Repository,
name?: string,
url?: string,
options?: { confirm?: boolean; fetch?: boolean },
) {
return executeGitCommand({
command: 'remote',
confirm: options?.confirm,
state: {
repo: repo,
subcommand: 'add',

Loading…
Cancel
Save