File tree Expand file tree Collapse file tree 6 files changed +11
-11
lines changed Expand file tree Collapse file tree 6 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ export const publish = async () => {
34
34
if ( ! worktree )
35
35
return showUserMessage ( 'Warn' , 'Aborted as no worktree was selected' ) ;
36
36
37
- await pushNewBranchToRemote ( worktree . path ) ;
37
+ await pushNewBranchToRemote ( worktree ) ;
38
38
39
39
showUserMessage (
40
40
'Info' ,
Original file line number Diff line number Diff line change @@ -67,5 +67,5 @@ export const shouldPushWorktree = async (worktree: IWorktree) => {
67
67
if ( answer !== noYesAskOptions . yes ) return ;
68
68
}
69
69
70
- await pushNewBranchToRemote ( worktree . path ) ;
70
+ await pushNewBranchToRemote ( worktree ) ;
71
71
} ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import type {
6
6
import { basename } from 'path' ;
7
7
import * as util from 'util' ;
8
8
import { workspace } from 'vscode' ;
9
- import { loggingOptions , loggingOptionValue } from '../config/constants' ;
9
+ import { loggingOptionValue , loggingOptions } from '../config/constants' ;
10
10
import { globalState } from '../extension' ;
11
11
import { isExistingDirectory } from './file' ;
12
12
Original file line number Diff line number Diff line change
1
+ import { type IWorktree } from '#/@types/worktree' ;
1
2
import {
2
3
BARE_REPOSITORY ,
3
4
BARE_REPOSITORY_REMOTE_ORIGIN_FETCH ,
@@ -148,9 +149,9 @@ export const getRemoteBranches = async (): Promise<string[]> => {
148
149
}
149
150
} ;
150
151
151
- export const pushNewBranchToRemote = async ( path : string ) => {
152
+ export const pushNewBranchToRemote = async ( { path, worktree } : IWorktree ) => {
152
153
try {
153
- const command = `git -C ${ path } push -u origin` ;
154
+ const command = `git -C ${ path } push --set-upstream origin ${ worktree } ` ;
154
155
await executeCommand ( command ) ;
155
156
} catch ( e : any ) {
156
157
throw Error ( e ) ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { calculateNewWorktreePath } from './calculateNewWorktreePath';
4
4
5
5
export const addNewWorktree = async (
6
6
newBranch : string ,
7
- trackingBranch ? : string
7
+ trackingBranch : string
8
8
) => {
9
9
const isExistingBranch = await checkIfBranchExistsOnRemote ( newBranch ) ;
10
10
if ( isExistingBranch )
@@ -15,10 +15,9 @@ export const addNewWorktree = async (
15
15
const newWorktree = { worktree : newBranch , path : newWorktreePath } ;
16
16
17
17
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 } ` ;
20
19
21
- await executeCommand ( trackingBranch ? addCommandWithTracking : addCommand ) ;
20
+ await executeCommand ( addCommand ) ;
22
21
23
22
return newWorktree ;
24
23
} catch ( e : any ) {
Original file line number Diff line number Diff line change @@ -25,8 +25,8 @@ export const shouldPushWorktree = async (
25
25
if ( ! answer ) return ;
26
26
if ( answer === noYesWindowOptions . no ) return ;
27
27
28
- return pushNewBranchToRemote ( worktree . path ) ;
28
+ return pushNewBranchToRemote ( worktree ) ;
29
29
}
30
30
31
- pushNewBranchToRemote ( worktree . path ) ;
31
+ pushNewBranchToRemote ( worktree ) ;
32
32
} ;
You can’t perform that action at this time.
0 commit comments