@@ -14,7 +14,7 @@ import * as filetype from 'file-type';
1414import { assign , groupBy , denodeify , IDisposable , toDisposable , dispose , mkdirp , readBytes , detectUnicodeEncoding , Encoding , onceEvent } from './util' ;
1515import { CancellationToken , Uri , workspace } from 'vscode' ;
1616import { detectEncoding } from './encoding' ;
17- import { Ref , RefType , Branch , Remote , GitErrorCodes , LogOptions , Change , Status } from './api/git' ;
17+ import { Ref , RefType , Branch , Remote , GitErrorCodes , LogOptions , Change , Status , TrackingShip } from './api/git' ;
1818
1919const readfile = denodeify < string , string | null , string > ( fs . readFile ) ;
2020
@@ -1578,6 +1578,21 @@ export class Repository {
15781578 }
15791579 }
15801580
1581+ async GetTracking ( upstreamBranch : string ) : Promise < TrackingShip [ ] > {
1582+ const result = await this . run ( [ 'for-each-ref' , '--format' , '%(if)%(upstream:short)%(then)%(refname:short)->%(upstream:short) %(else)* %(end)' , 'refs/heads' ] ) ;
1583+ return result . stdout . trim ( ) . split ( '\n' )
1584+ . map ( line => line . trim ( ) )
1585+ . filter ( line => line !== '*' )
1586+ . map ( line => {
1587+ const splited = line . split ( '->' ) ;
1588+ return {
1589+ local : splited [ 0 ] ,
1590+ upstream : splited [ 1 ]
1591+ } as TrackingShip ;
1592+ } )
1593+ . filter ( trackingShip => trackingShip . upstream === upstreamBranch ) ;
1594+ }
1595+
15811596 async getRefs ( ) : Promise < Ref [ ] > {
15821597 const result = await this . run ( [ 'for-each-ref' , '--format' , '%(refname) %(objectname)' , '--sort' , '-committerdate' ] ) ;
15831598
0 commit comments