1
1
import * as vscode from 'vscode' ;
2
2
import * as path from 'path' ;
3
3
4
- import { CodingServer } from '../codingServer' ;
5
- import { RepoInfo , SessionData } from '../typings/commonTypes' ;
6
- import { IMRDiffStat , IMRData , IMRPathItem } from '../typings/respResult' ;
4
+ import { CodingServer } from '../codingServer' ;
5
+ import { RepoInfo , SessionData } from '../typings/commonTypes' ;
6
+ import { IMRDiffStat , IMRData , IMRPathItem } from '../typings/respResult' ;
7
7
8
8
enum MRType {
9
9
Open = `open` ,
@@ -21,6 +21,8 @@ enum ItemType {
21
21
export interface IFileNode extends IMRPathItem {
22
22
parentPath ?: string ;
23
23
children ?: IFileNode [ ]
24
+ newSha ?: string ;
25
+ oldSha ?: string ;
24
26
}
25
27
26
28
type ITreeNode = string | number | IMRDiffStat | IFileNode | IMRData ;
@@ -74,7 +76,7 @@ export class MRTreeDataProvider implements vscode.TreeDataProvider<ListItem<ITre
74
76
return [ ] ;
75
77
}
76
78
77
- const { data : { list} } = resp ;
79
+ const { data : { list } } = resp ;
78
80
if ( ! list . length ) {
79
81
return [
80
82
new ListItem ( `0 merge requests in this category` , `noData` , vscode . TreeItemCollapsibleState . None ) ,
@@ -91,7 +93,7 @@ export class MRTreeDataProvider implements vscode.TreeDataProvider<ListItem<ITre
91
93
i . title ,
92
94
i ,
93
95
vscode . TreeItemCollapsibleState . Collapsed ,
94
- this . _context
96
+ this . _context ,
95
97
) ;
96
98
} ) ;
97
99
} )
@@ -101,7 +103,7 @@ export class MRTreeDataProvider implements vscode.TreeDataProvider<ListItem<ITre
101
103
}
102
104
case ItemType . MRItem : {
103
105
return this . _service . getMRDiff ( ( element . value as IMRData ) . iid )
104
- . then ( ( { data : { diffStat} } ) => {
106
+ . then ( ( { data : { diffStat } } ) => {
105
107
return element . getChildren ( diffStat ) ;
106
108
} ) ;
107
109
}
@@ -153,7 +155,7 @@ export class MRItem extends ListItem<IMRData> {
153
155
}
154
156
155
157
async getChildren ( diffStat : IMRDiffStat ) : Promise < ListItem < string | number | IFileNode > [ ] > {
156
- const files = this . _transformTree ( diffStat . paths ) ;
158
+ const files = this . _transformTree ( diffStat ) ;
157
159
const repoInfo = this . context . workspaceState . get ( `repoInfo` , { } ) ;
158
160
const session = this . context . workspaceState . get ( `session` , { } as SessionData ) ;
159
161
@@ -176,10 +178,10 @@ export class MRItem extends ListItem<IMRData> {
176
178
] ;
177
179
}
178
180
179
- private _transformTree ( paths : IMRPathItem [ ] ) {
181
+ private _transformTree ( diff : IMRDiffStat ) {
180
182
let nodes : IFileNode [ ] = [ ] ;
181
- paths . forEach ( p => {
182
- nodes = this . _makeTree ( p , nodes ) ;
183
+ diff . paths . forEach ( p => {
184
+ nodes = this . _makeTree ( { ... p , newSha : diff . newSha , oldSha : diff . oldSha } , nodes ) ;
183
185
} ) ;
184
186
185
187
return nodes ;
@@ -191,7 +193,7 @@ export class MRItem extends ListItem<IMRData> {
191
193
rawArr . forEach ( ( i , idx ) => {
192
194
const curPath = rawArr . slice ( 0 , idx + 1 ) . join ( `/` ) ;
193
195
const parentPath = rawArr . slice ( 0 , idx ) . join ( `/` ) ;
194
- const f = { ...node , name : i , path : curPath , parentPath, children : [ ] } ;
196
+ const f = { ...node , name : i , path : curPath , parentPath, children : [ ] } ;
195
197
nodes = this . _insert ( f , nodes ) ;
196
198
} ) ;
197
199
@@ -243,8 +245,8 @@ export class FileNode extends ListItem<IFileNode> {
243
245
collapsibleState === vscode . TreeItemCollapsibleState . None ? {
244
246
command : `codingPlugin.showDiff` ,
245
247
title : `` ,
246
- arguments : [ value ]
247
- } : undefined
248
+ arguments : [ value ] ,
249
+ } : undefined ,
248
250
) ;
249
251
}
250
252
0 commit comments