Skip to content

Commit d0ed9dc

Browse files
Phil Stainerphilstainer
authored andcommitted
fix: push upstream
1 parent 5449c44 commit d0ed9dc

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

src/commands/publish.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const publish = async () => {
3434
if (!worktree)
3535
return showUserMessage('Warn', 'Aborted as no worktree was selected');
3636

37-
await pushNewBranchToRemote(worktree.path);
37+
await pushNewBranchToRemote(worktree);
3838

3939
showUserMessage(
4040
'Info',

src/commands/rename.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,5 @@ export const shouldPushWorktree = async (worktree: IWorktree) => {
6767
if (answer !== noYesAskOptions.yes) return;
6868
}
6969

70-
await pushNewBranchToRemote(worktree.path);
70+
await pushNewBranchToRemote(worktree);
7171
};

src/helpers/general.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
import { basename } from 'path';
77
import * as util from 'util';
88
import { workspace } from 'vscode';
9-
import { loggingOptions, loggingOptionValue } from '../config/constants';
9+
import { loggingOptionValue, loggingOptions } from '../config/constants';
1010
import { globalState } from '../extension';
1111
import { isExistingDirectory } from './file';
1212

src/helpers/git.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { type IWorktree } from '#/@types/worktree';
12
import {
23
BARE_REPOSITORY,
34
BARE_REPOSITORY_REMOTE_ORIGIN_FETCH,
@@ -148,9 +149,9 @@ export const getRemoteBranches = async (): Promise<string[]> => {
148149
}
149150
};
150151

151-
export const pushNewBranchToRemote = async (path: string) => {
152+
export const pushNewBranchToRemote = async ({ path, worktree }: IWorktree) => {
152153
try {
153-
const command = `git -C ${path} push -u origin`;
154+
const command = `git -C ${path} push --set-upstream origin ${worktree}`;
154155
await executeCommand(command);
155156
} catch (e: any) {
156157
throw Error(e);

src/helpers/worktree/addNewWorktree.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { calculateNewWorktreePath } from './calculateNewWorktreePath';
44

55
export const addNewWorktree = async (
66
newBranch: string,
7-
trackingBranch?: string
7+
trackingBranch: string
88
) => {
99
const isExistingBranch = await checkIfBranchExistsOnRemote(newBranch);
1010
if (isExistingBranch)
@@ -15,10 +15,9 @@ export const addNewWorktree = async (
1515
const newWorktree = { worktree: newBranch, path: newWorktreePath };
1616

1717
try {
18-
const addCommand = `git worktree add -B ${newBranch} ${newWorktreePath}`;
19-
const addCommandWithTracking = `git worktree add --track -B ${newBranch} ${newWorktreePath} origin/${trackingBranch}`;
18+
const addCommand = `git worktree add --track -B ${newBranch} ${newWorktreePath} origin/${trackingBranch}`;
2019

21-
await executeCommand(trackingBranch ? addCommandWithTracking : addCommand);
20+
await executeCommand(addCommand);
2221

2322
return newWorktree;
2423
} catch (e: any) {

src/helpers/worktree/shouldPushWorktree.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export const shouldPushWorktree = async (
2525
if (!answer) return;
2626
if (answer === noYesWindowOptions.no) return;
2727

28-
return pushNewBranchToRemote(worktree.path);
28+
return pushNewBranchToRemote(worktree);
2929
}
3030

31-
pushNewBranchToRemote(worktree.path);
31+
pushNewBranchToRemote(worktree);
3232
};

0 commit comments

Comments
 (0)