@ -45,6 +45,7 @@ import {
} from './nodes' ;
} from './nodes' ;
import { Strings } from '../system/string' ;
import { Strings } from '../system/string' ;
import { runGitCommandInTerminal } from '../terminal' ;
import { runGitCommandInTerminal } from '../terminal' ;
import { ReferencesQuickPick } from '../quickpicks' ;
interface CompareSelectedInfo {
interface CompareSelectedInfo {
ref : string ;
ref : string ;
@ -243,25 +244,37 @@ export class ViewCommands {
return Container . git . checkout ( node . repoPath , node . ref , { fileName : node.fileName } ) ;
return Container . git . checkout ( node . repoPath , node . ref , { fileName : node.fileName } ) ;
}
}
if ( node instanceof BranchNode && node . branch . remote ) {
const branches = await Container . git . getBranches ( node . repoPath , {
filter : b = > {
return b . tracking === node . branch . name ;
}
} ) ;
if ( node instanceof BranchNode ) {
let branch = node . branch ;
if ( branch . current ) {
const pick = await new ReferencesQuickPick ( node . repoPath ) . show ( 'Choose a branch to check out to' , { checkmarks : false , filterBranches : b = > ! b . current , include : 'branches' } ) ;
if ( pick === undefined ) return undefined ;
if ( branches . length !== 0 ) {
return Container . git . checkout ( node . repoPath , branches [ 0 ] . ref ) ;
branch = pick . item ;
}
}
const name = await window . showInputBox ( {
prompt : "Please provide a name for the local branch (Press 'Enter' to confirm or 'Escape' to cancel)" ,
placeHolder : 'Local branch name' ,
value : node.branch.getName ( )
} ) ;
if ( name === undefined || name . length === 0 ) return undefined ;
if ( branch . remote ) {
const branches = await Container . git . getBranches ( node . repoPath , {
filter : b = > {
return b . tracking === branch . name ;
}
} ) ;
if ( branches . length !== 0 ) {
return Container . git . checkout ( node . repoPath , branches [ 0 ] . ref ) ;
}
const name = await window . showInputBox ( {
prompt : "Please provide a name for the local branch (Press 'Enter' to confirm or 'Escape' to cancel)" ,
placeHolder : 'Local branch name' ,
value : branch.getName ( )
} ) ;
if ( name === undefined || name . length === 0 ) return undefined ;
return Container . git . checkout ( node . repoPath , branch . ref , { createBranch : name } ) ;
}
return Container . git . checkout ( node . repoPath , node . ref , { createBranch : name } ) ;
return Container . git . checkout ( branch . repoPath , branch . ref ) ;
}
}
return Container . git . checkout ( node . repoPath , node . ref ) ;
return Container . git . checkout ( node . repoPath , node . ref ) ;