@ -83,7 +83,7 @@ import { GitActions } from './gitCommands.actions';
export function appendReposToTitle <
State extends { repo : Repository } | { repos : Repository [ ] } ,
Context extends { repos : Repository [ ] }
Context extends { repos : Repository [ ] } ,
> ( title : string , state : State , context : Context , additionalContext? : string ) {
if ( context . repos . length === 1 ) {
return ` ${ title } ${ Strings . truncate ( additionalContext ? ? '' , quickPickTitleMaxChars - title . length ) } ` ;
@ -319,7 +319,7 @@ export function getValidateGitReferenceFn(repos: Repository | Repository[], opti
export async function * inputBranchNameStep <
State extends PartialStepState & ( { repo : Repository } | { repos : Repository [ ] } ) ,
Context extends { repos : Repository [ ] ; showTags? : boolean ; title : string }
Context extends { repos : Repository [ ] ; showTags? : boolean ; title : string } ,
> (
state : State ,
context : Context ,
@ -354,7 +354,7 @@ export async function* inputBranchNameStep<
export async function * inputTagNameStep <
State extends PartialStepState & ( { repo : Repository } | { repos : Repository [ ] } ) ,
Context extends { repos : Repository [ ] ; showTags? : boolean ; title : string }
Context extends { repos : Repository [ ] ; showTags? : boolean ; title : string } ,
> (
state : State ,
context : Context ,
@ -389,7 +389,7 @@ export async function* inputTagNameStep<
export async function * pickBranchStep <
State extends PartialStepState & { repo : Repository } ,
Context extends { repos : Repository [ ] ; showTags? : boolean ; title : string }
Context extends { repos : Repository [ ] ; showTags? : boolean ; title : string } ,
> (
state : State ,
context : Context ,
@ -453,7 +453,7 @@ export async function* pickBranchStep<
export async function * pickBranchesStep <
State extends PartialStepState & { repo : Repository } ,
Context extends { repos : Repository [ ] ; showTags? : boolean ; title : string }
Context extends { repos : Repository [ ] ; showTags? : boolean ; title : string } ,
> (
state : State ,
context : Context ,
@ -521,7 +521,7 @@ export async function* pickBranchesStep<
export async function * pickBranchOrTagStep <
State extends PartialStepState & { repo : Repository } ,
Context extends { repos : Repository [ ] ; showTags? : boolean ; title : string }
Context extends { repos : Repository [ ] ; showTags? : boolean ; title : string } ,
> (
state : State ,
context : Context ,
@ -638,7 +638,7 @@ export async function* pickBranchOrTagStep<
export async function * pickBranchOrTagStepMultiRepo <
State extends StepState & { repos : Repository [ ] ; reference? : GitReference } ,
Context extends { repos : Repository [ ] ; showTags? : boolean ; title : string }
Context extends { repos : Repository [ ] ; showTags? : boolean ; title : string } ,
> (
state : State ,
context : Context ,
@ -753,7 +753,7 @@ export async function* pickBranchOrTagStepMultiRepo<
export async function * pickCommitStep <
State extends PartialStepState & { repo : Repository } ,
Context extends { repos : Repository [ ] ; title : string }
Context extends { repos : Repository [ ] ; title : string } ,
> (
state : State ,
context : Context ,
@ -906,7 +906,7 @@ export async function* pickCommitStep<
export function * pickCommitsStep <
State extends PartialStepState & { repo : Repository } ,
Context extends { repos : Repository [ ] ; title : string }
Context extends { repos : Repository [ ] ; title : string } ,
> (
state : State ,
context : Context ,
@ -1024,7 +1024,7 @@ export function* pickCommitsStep<
export async function * pickContributorsStep <
State extends PartialStepState & { repo : Repository } ,
Context extends { repos : Repository [ ] ; title : string }
Context extends { repos : Repository [ ] ; title : string } ,
> (
state : State ,
context : Context ,
@ -1048,7 +1048,7 @@ export async function* pickContributorsStep<
export async function * pickRepositoryStep <
State extends PartialStepState & { repo? : string | Repository } ,
Context extends { repos : Repository [ ] ; title : string }
Context extends { repos : Repository [ ] ; title : string } ,
> ( state : State , context : Context , placeholder : string = 'Choose a repository' ) : AsyncStepResultGenerator < Repository > {
if ( typeof state . repo === 'string' ) {
state . repo = await Container . git . getRepository ( state . repo ) ;
@ -1099,7 +1099,7 @@ export async function* pickRepositoryStep<
export async function * pickRepositoriesStep <
State extends PartialStepState & { repos? : string [ ] | Repository [ ] } ,
Context extends { repos : Repository [ ] ; title : string }
Context extends { repos : Repository [ ] ; title : string } ,
> (
state : State ,
context : Context ,
@ -1170,7 +1170,7 @@ export async function* pickRepositoriesStep<
export function * pickStashStep <
State extends PartialStepState & { repo : Repository } ,
Context extends { repos : Repository [ ] ; title : string }
Context extends { repos : Repository [ ] ; title : string } ,
> (
state : State ,
context : Context ,
@ -1262,7 +1262,7 @@ export function* pickStashStep<
export async function * pickTagsStep <
State extends PartialStepState & { repo : Repository } ,
Context extends { repos : Repository [ ] ; showTags? : boolean ; title : string }
Context extends { repos : Repository [ ] ; showTags? : boolean ; title : string } ,
> (
state : State ,
context : Context ,
@ -1327,75 +1327,74 @@ export async function* pickTagsStep<
export async function * showCommitOrStashStep <
State extends PartialStepState & { repo : Repository ; reference : GitLogCommit | GitStashCommit } ,
Context extends { repos : Repository [ ] ; title : string }
Context extends { repos : Repository [ ] ; title : string } ,
> (
state : State ,
context : Context ,
) : AsyncStepResultGenerator < CommitFilesQuickPickItem | GitCommandQuickPickItem | CommandQuickPickItem > {
const step : QuickPickStep <
CommitFilesQuickPickItem | GitCommandQuickPickItem | CommandQuickPickItem
> = QuickCommand . createPickStep ( {
title : appendReposToTitle (
GitReference . toString ( state . reference , {
capitalize : tru e,
icon : false ,
} ) ,
state ,
context ,
) ,
placeholder : GitReference.toString ( state . reference , { capitalize : true , icon : false } ) ,
ignoreFocusOut : true ,
items : await getShowCommitOrStashStepItems ( state ) ,
additionalButtons : GitReference.isStash ( state . reference )
? [ QuickCommandButtons . RevealInSideBar ]
: [ QuickCommandButtons . RevealInSideBar , QuickCommandButtons . SearchInSideBar ] ,
onDidClickButton : ( quickpick , button ) = > {
if ( button === QuickCommandButtons . SearchInSideBar ) {
void Container . searchAndCompareView . search (
state . repo . path ,
{ pattern : SearchPattern.fromCommit ( state . reference . ref ) } ,
{
label : { label : ` for ${ GitReference . toString ( state . reference , { icon : false } )} ` } ,
reveal : {
select : tru e,
focus : fals e,
expand : true ,
const step : QuickPickStep < CommitFilesQuickPickItem | GitCommandQuickPickItem | CommandQuickPickItem > =
QuickCommand . createPickStep ( {
title : appendReposToTitle (
GitReference . toString ( state . reference , {
capitalize : true ,
icon : fals e ,
} ) ,
state ,
context ,
) ,
placeholder : GitReference.toString ( state . reference , { capitalize : true , icon : false } ) ,
ignoreFocusOut : true ,
items : await getShowCommitOrStashStepItems ( state ) ,
additionalButtons : GitReference.isStash ( state . reference )
? [ QuickCommandButtons . RevealInSideBar ]
: [ QuickCommandButtons . RevealInSideBar , QuickCommandButtons . SearchInSideBar ],
onDidClickButton : ( quickpick , button ) = > {
if ( button === QuickCommandButtons . SearchInSideBar ) {
void Container . searchAndCompareView . search (
state . repo . path ,
{ pattern : SearchPattern.fromCommit ( state . reference . ref ) } ,
{
label : { label : ` for ${ GitReference . toString ( state . reference , { icon : false } )} ` } ,
reveal : {
select : true ,
focus : fals e ,
expand : tru e ,
} ,
} ,
} ,
) ;
) ;
return ;
}
return ;
}
if ( button === QuickCommandButtons . RevealInSideBar ) {
if ( GitReference . isStash ( state . reference ) ) {
void GitActions . Stash . reveal ( state . reference , {
select : true ,
focus : false ,
expand : true ,
} ) ;
} else {
void GitActions . Commit . reveal ( state . reference , {
select : true ,
focus : false ,
expand : true ,
} ) ;
if ( button === QuickCommandButtons . RevealInSideBar ) {
if ( GitReference . isStash ( state . reference ) ) {
void GitActions . Stash . reveal ( state . reference , {
select : true ,
focus : false ,
expand : true ,
} ) ;
} else {
void GitActions . Commit . reveal ( state . reference , {
select : true ,
focus : false ,
expand : true ,
} ) ;
}
}
}
} ,
keys : [ 'right' , 'alt+right' , 'ctrl+right' ] ,
onDidPressKey : async ( quickpick , key ) = > {
if ( quickpick . activeItems . length === 0 ) return ;
} ,
keys : [ 'right' , 'alt+right' , 'ctrl+right' ] ,
onDidPressKey : async ( quickpick , key ) = > {
if ( quickpick . activeItems . length === 0 ) return ;
void ( await quickpick . activeItems [ 0 ] . onDidPressKey ( key ) ) ;
} ,
} ) ;
void ( await quickpick . activeItems [ 0 ] . onDidPressKey ( key ) ) ;
} ,
} ) ;
const selection : StepSelection < typeof step > = yield step ;
return QuickCommand . canPickStepContinue ( step , state , selection ) ? selection [ 0 ] : StepResult . Break ;
}
async function getShowCommitOrStashStepItems <
State extends PartialStepState & { repo : Repository ; reference : GitLogCommit | GitStashCommit }
State extends PartialStepState & { repo : Repository ; reference : GitLogCommit | GitStashCommit } ,
> ( state : State ) {
const items : CommandQuickPickItem [ ] = [ new CommitFilesQuickPickItem ( state . reference ) ] ;
@ -1579,7 +1578,7 @@ export function* showCommitOrStashFilesStep<
reference : GitLogCommit | GitStashCommit ;
fileName? : string | undefined ;
} ,
Context extends { repos : Repository [ ] ; title : string }
Context extends { repos : Repository [ ] ; title : string } ,
> (
state : State ,
context : Context ,
@ -1655,7 +1654,7 @@ export async function* showCommitOrStashFileStep<
reference : GitLogCommit | GitStashCommit ;
fileName : string ;
} ,
Context extends { repos : Repository [ ] ; title : string }
Context extends { repos : Repository [ ] ; title : string } ,
> ( state : State , context : Context ) : AsyncStepResultGenerator < CommandQuickPickItem > {
const step : QuickPickStep < CommandQuickPickItem > = QuickCommand . createPickStep < CommandQuickPickItem > ( {
title : appendReposToTitle (
@ -1726,7 +1725,7 @@ async function getShowCommitOrStashFileStepItems<
repo : Repository ;
reference : GitLogCommit | GitStashCommit ;
fileName : string ;
}
} ,
> ( state : State ) {
const file = state . reference . files . find ( f = > f . fileName === state . fileName ) ;
if ( file == null ) return [ ] ;
@ -1819,7 +1818,7 @@ async function getShowCommitOrStashFileStepItems<
export function * showRepositoryStatusStep <
State extends PartialStepState & { repo : Repository } ,
Context extends { repos : Repository [ ] ; title : string ; status : GitStatus }
Context extends { repos : Repository [ ] ; title : string ; status : GitStatus } ,
> ( state : State , context : Context ) : StepResultGenerator < CommandQuickPickItem > {
const upstream = context . status . getUpstreamStatus ( { expand : true , separator : ', ' } ) ;
const working = context . status . getFormattedDiffStatus ( { expand : true , separator : ', ' } ) ;
@ -1841,7 +1840,7 @@ export function* showRepositoryStatusStep<
function getShowRepositoryStatusStepItems <
State extends PartialStepState & { repo : Repository } ,
Context extends { repos : Repository [ ] ; title : string ; status : GitStatus }
Context extends { repos : Repository [ ] ; title : string ; status : GitStatus } ,
> ( state : State , context : Context ) {
const items : ( DirectiveQuickPickItem | CommandQuickPickItem ) [ ] = [ ] ;