11import { ISettingRegistry } from '@jupyterlab/coreutils' ;
22import { IRenderMimeRegistry } from '@jupyterlab/rendermime' ;
33import * as React from 'react' ;
4- import { GitExtension , BranchMarker } from '../model' ;
4+ import { GitExtension } from '../model' ;
55import {
66 findRepoButtonStyle ,
77 panelContainerStyle ,
88 panelWarningStyle
99} from '../style/GitPanelStyle' ;
1010import { Git } from '../tokens' ;
11+ import { decodeStage } from '../utils' ;
1112import { BranchHeader } from './BranchHeader' ;
1213import { FileList } from './FileList' ;
1314import { HistorySideBar } from './HistorySideBar' ;
@@ -28,8 +29,6 @@ export interface IGitSessionNodeState {
2829 untrackedFiles : Git . IStatusFileResult [ ] ;
2930 hasChangedFiles : boolean ;
3031
31- marker : BranchMarker ;
32-
3332 isHistoryVisible : boolean ;
3433}
3534
@@ -57,7 +56,6 @@ export class GitPanel extends React.Component<
5756 stagedFiles : [ ] ,
5857 unstagedFiles : [ ] ,
5958 untrackedFiles : [ ] ,
60- marker : null ,
6159 isHistoryVisible : false
6260 } ;
6361
@@ -99,14 +97,15 @@ export class GitPanel extends React.Component<
9997 }
10098 }
10199
100+ this . props . model . getMarker (
101+ this . props . model . pathRepository ,
102+ currentBranch
103+ ) ;
104+
102105 this . setState ( {
103106 branches : branchData . branches ,
104107 currentBranch : currentBranch ,
105- upstreamBranch : upstreamBranch ,
106- marker : this . props . model . getMarker (
107- this . props . model . pathRepository ,
108- currentBranch
109- )
108+ upstreamBranch : upstreamBranch
110109 } ) ;
111110 }
112111 } ;
@@ -138,32 +137,26 @@ export class GitPanel extends React.Component<
138137 let statusFiles = this . props . model . status ;
139138 if ( statusFiles . length > 0 ) {
140139 for ( let i = 0 ; i < statusFiles . length ; i ++ ) {
140+ const file = statusFiles [ i ] ;
141+ const { x, y } = file ;
142+ const stage = decodeStage ( x , y ) ;
143+
141144 // If file has been changed
142- if ( statusFiles [ i ] . x !== '?' && statusFiles [ i ] . x !== '!' ) {
145+ if ( x !== '?' && x !== '!' ) {
143146 changedFiles ++ ;
144147 }
148+
145149 // If file is untracked
146- if ( statusFiles [ i ] . x === '?' && statusFiles [ i ] . y === '?' ) {
147- untrackedFiles . push ( statusFiles [ i ] ) ;
148- } else {
149- // If file is staged
150- if ( statusFiles [ i ] . x !== ' ' && statusFiles [ i ] . y !== 'D' ) {
151- stagedFiles . push ( statusFiles [ i ] ) ;
152- }
153- // If file is unstaged but tracked
154- if ( statusFiles [ i ] . y !== ' ' ) {
155- unstagedFiles . push ( statusFiles [ i ] ) ;
156- }
150+ if ( stage === 'untracked' ) {
151+ untrackedFiles . push ( file ) ;
152+ } else if ( stage === 'unstaged' ) {
153+ unstagedFiles . push ( file ) ;
154+ } else if ( stage === 'staged' ) {
155+ stagedFiles . push ( file ) ;
157156 }
158157 }
159158 }
160159
161- this . state . marker . addMarked (
162- ...stagedFiles . map ( x => x . to ) ,
163- ...unstagedFiles . map ( x => x . to )
164- ) ;
165- this . state . marker . addUnmarked ( ...untrackedFiles . map ( x => x . to ) ) ;
166-
167160 this . setState ( {
168161 stagedFiles : stagedFiles ,
169162 unstagedFiles : unstagedFiles ,
0 commit comments