@@ -15,12 +15,13 @@ export const AnyCommandLineRegex = /.+/;
15
15
export const GitSimilarOutputRegex = / m o s t s i m i l a r c o m m a n d i s \s * ( [ ^ \s ] { 3 , } ) / ;
16
16
export const FreePortOutputRegex = / a d d r e s s a l r e a d y i n u s e \d + \. \d + \. \d + \. \d + : ( \d { 4 , 5 } ) | U n a b l e t o b i n d [ ^ ] * : ( \d { 4 , 5 } ) | c a n ' t l i s t e n o n p o r t ( \d { 4 , 5 } ) | l i s t e n E A D D R I N U S E [ ^ ] * : ( \d { 4 , 5 } ) / ;
17
17
export const GitPushOutputRegex = / g i t p u s h - - s e t - u p s t r e a m o r i g i n ( [ ^ \s ] + ) / ;
18
- export const GitCreatePrOutputRegex = / C r e a t e a p u l l r e q u e s t f o r \' ( [ ^ \s ] + ) \' o n G i t H u b b y v i s i t i n g : \s * r e m o t e : \s * ( h t t p s : .+ p u l l .+ ) / ;
18
+ // The previous line starts with "Create a pull request for \'([^\s]+)\' on GitHub by visiting:\s*",
19
+ // it's safe to assume it's a github pull request if the URL includes `/pull/`
20
+ export const GitCreatePrOutputRegex = / r e m o t e : \s * ( h t t p s : \/ \/ g i t h u b \. c o m \/ .+ \/ .+ \/ p u l l \/ n e w \/ .+ ) / ;
19
21
20
22
export function gitSimilarCommand ( ) : ITerminalQuickFixOptions {
21
23
return {
22
24
commandLineMatcher : GitCommandLineRegex ,
23
- quickFixLabel : ( matchResult : QuickFixMatchResult ) => matchResult . outputMatch ? `Run git ${ matchResult . outputMatch [ 1 ] } ` : `` ,
24
25
outputMatcher : {
25
26
lineMatcher : GitSimilarOutputRegex ,
26
27
anchor : 'bottom' ,
@@ -34,10 +35,11 @@ export function gitSimilarCommand(): ITerminalQuickFixOptions {
34
35
if ( ! fixedCommand ) {
35
36
return ;
36
37
}
37
- const label = localize ( "terminal.gitSimilarCommand" , "Run git {0}" , fixedCommand ) ;
38
+ const commandToRunInTerminal = `git ${ fixedCommand } ` ;
39
+ const label = localize ( "terminal.runCommand" , "Run: {0}" , commandToRunInTerminal ) ;
38
40
actions . push ( {
39
41
class : undefined , tooltip : label , id : 'terminal.gitSimilarCommand' , label, enabled : true ,
40
- commandToRunInTerminal : `git ${ fixedCommand } ` ,
42
+ commandToRunInTerminal,
41
43
addNewLine : true ,
42
44
run : ( ) => { }
43
45
} ) ;
@@ -47,7 +49,6 @@ export function gitSimilarCommand(): ITerminalQuickFixOptions {
47
49
}
48
50
export function freePort ( terminalInstance ?: Partial < ITerminalInstance > ) : ITerminalQuickFixOptions {
49
51
return {
50
- quickFixLabel : ( matchResult : QuickFixMatchResult ) => matchResult . outputMatch ? `Free port ${ matchResult . outputMatch [ 1 ] } ` : '' ,
51
52
commandLineMatcher : AnyCommandLineRegex ,
52
53
outputMatcher : {
53
54
lineMatcher : FreePortOutputRegex ,
@@ -77,7 +78,6 @@ export function freePort(terminalInstance?: Partial<ITerminalInstance>): ITermin
77
78
}
78
79
export function gitPushSetUpstream ( ) : ITerminalQuickFixOptions {
79
80
return {
80
- quickFixLabel : ( matchResult : QuickFixMatchResult ) => matchResult . outputMatch ? `Git push ${ matchResult . outputMatch [ 1 ] } ` : '' ,
81
81
commandLineMatcher : GitPushCommandLineRegex ,
82
82
outputMatcher : {
83
83
lineMatcher : GitPushOutputRegex ,
@@ -92,11 +92,11 @@ export function gitPushSetUpstream(): ITerminalQuickFixOptions {
92
92
return ;
93
93
}
94
94
const actions : ITerminalQuickFixAction [ ] = [ ] ;
95
- const label = localize ( "terminal.gitPush" , "Git push {0}" , branch ) ;
96
- command . command = `git push --set-upstream origin ${ branch } ` ;
95
+ const commandToRunInTerminal = `git push --set-upstream origin ${ branch } ` ;
96
+ const label = localize ( "terminal.runCommand" , "Run: {0}" , commandToRunInTerminal ) ;
97
97
actions . push ( {
98
98
class : undefined , tooltip : label , id : 'terminal.gitPush' , label, enabled : true ,
99
- commandToRunInTerminal : command . command ,
99
+ commandToRunInTerminal,
100
100
addNewLine : true ,
101
101
run : ( ) => { }
102
102
} ) ;
@@ -107,7 +107,6 @@ export function gitPushSetUpstream(): ITerminalQuickFixOptions {
107
107
108
108
export function gitCreatePr ( openerService : IOpenerService ) : ITerminalQuickFixOptions {
109
109
return {
110
- quickFixLabel : ( matchResult : QuickFixMatchResult ) => matchResult . outputMatch ? `Create PR for ${ matchResult . outputMatch [ 1 ] } ` : '' ,
111
110
commandLineMatcher : GitPushCommandLineRegex ,
112
111
outputMatcher : {
113
112
lineMatcher : GitCreatePrOutputRegex ,
@@ -120,13 +119,12 @@ export function gitCreatePr(openerService: IOpenerService): ITerminalQuickFixOpt
120
119
if ( ! command ) {
121
120
return ;
122
121
}
123
- const branch = matchResult ?. outputMatch ?. [ 1 ] ;
124
- const link = matchResult ?. outputMatch ?. [ 2 ] ;
125
- if ( ! branch || ! link ) {
122
+ const link = matchResult ?. outputMatch ?. [ 1 ] ;
123
+ if ( ! link ) {
126
124
return ;
127
125
}
128
126
const actions : IAction [ ] = [ ] ;
129
- const label = localize ( "terminal.gitCreatePr " , "Create PR" ) ;
127
+ const label = localize ( "terminal.openLink " , "Open link: {0}" , link ) ;
130
128
actions . push ( {
131
129
class : undefined , tooltip : label , id : 'terminal.gitCreatePr' , label, enabled : true ,
132
130
run : ( ) => openerService . open ( link )
0 commit comments