Skip to content

Commit 0b42cfb

Browse files
committed
Make Node.path private
This is in preparation for changing the meaning of path in the next commit.
1 parent 3f4cb8b commit 0b42cfb

File tree

8 files changed

+106
-105
lines changed

8 files changed

+106
-105
lines changed

pkg/gui/filetree/build_tree.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func BuildTreeFromFiles(files []*models.File) *Node[models.File] {
4141
}
4242

4343
newChild := &Node[models.File]{
44-
Path: path,
44+
path: path,
4545
File: setFile,
4646
}
4747
curr.Children = append(curr.Children, newChild)
@@ -83,14 +83,14 @@ func BuildTreeFromCommitFiles(files []*models.CommitFile) *Node[models.CommitFil
8383
path := join(splitPath[:i+1])
8484

8585
for _, existingChild := range curr.Children {
86-
if existingChild.Path == path {
86+
if existingChild.path == path {
8787
curr = existingChild
8888
continue outer
8989
}
9090
}
9191

9292
newChild := &Node[models.CommitFile]{
93-
Path: path,
93+
path: path,
9494
File: setFile,
9595
}
9696
curr.Children = append(curr.Children, newChild)

pkg/gui/filetree/build_tree_test.go

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func TestBuildTreeFromFiles(t *testing.T) {
1717
name: "no files",
1818
files: []*models.File{},
1919
expected: &Node[models.File]{
20-
Path: "",
20+
path: "",
2121
Children: nil,
2222
},
2323
},
@@ -32,18 +32,18 @@ func TestBuildTreeFromFiles(t *testing.T) {
3232
},
3333
},
3434
expected: &Node[models.File]{
35-
Path: "",
35+
path: "",
3636
Children: []*Node[models.File]{
3737
{
38-
Path: "dir1",
38+
path: "dir1",
3939
Children: []*Node[models.File]{
4040
{
4141
File: &models.File{Path: "dir1/a"},
42-
Path: "dir1/a",
42+
path: "dir1/a",
4343
},
4444
{
4545
File: &models.File{Path: "dir1/b"},
46-
Path: "dir1/b",
46+
path: "dir1/b",
4747
},
4848
},
4949
},
@@ -61,24 +61,24 @@ func TestBuildTreeFromFiles(t *testing.T) {
6161
},
6262
},
6363
expected: &Node[models.File]{
64-
Path: "",
64+
path: "",
6565
Children: []*Node[models.File]{
6666
{
67-
Path: "dir1/dir3",
67+
path: "dir1/dir3",
6868
Children: []*Node[models.File]{
6969
{
7070
File: &models.File{Path: "dir1/dir3/a"},
71-
Path: "dir1/dir3/a",
71+
path: "dir1/dir3/a",
7272
},
7373
},
7474
CompressionLevel: 1,
7575
},
7676
{
77-
Path: "dir2/dir4",
77+
path: "dir2/dir4",
7878
Children: []*Node[models.File]{
7979
{
8080
File: &models.File{Path: "dir2/dir4/b"},
81-
Path: "dir2/dir4/b",
81+
path: "dir2/dir4/b",
8282
},
8383
},
8484
CompressionLevel: 1,
@@ -97,15 +97,15 @@ func TestBuildTreeFromFiles(t *testing.T) {
9797
},
9898
},
9999
expected: &Node[models.File]{
100-
Path: "",
100+
path: "",
101101
Children: []*Node[models.File]{
102102
{
103103
File: &models.File{Path: "a"},
104-
Path: "a",
104+
path: "a",
105105
},
106106
{
107107
File: &models.File{Path: "b"},
108-
Path: "b",
108+
path: "b",
109109
},
110110
},
111111
},
@@ -125,21 +125,21 @@ func TestBuildTreeFromFiles(t *testing.T) {
125125
},
126126
},
127127
expected: &Node[models.File]{
128-
Path: "",
128+
path: "",
129129
// it is a little strange that we're not bubbling up our merge conflict
130130
// here but we are technically still in tree mode and that's the rule
131131
Children: []*Node[models.File]{
132132
{
133133
File: &models.File{Path: "a"},
134-
Path: "a",
134+
path: "a",
135135
},
136136
{
137137
File: &models.File{Path: "b"},
138-
Path: "b",
138+
path: "b",
139139
},
140140
{
141141
File: &models.File{Path: "z", HasMergeConflicts: true},
142-
Path: "z",
142+
path: "z",
143143
},
144144
},
145145
},
@@ -164,7 +164,7 @@ func TestBuildFlatTreeFromFiles(t *testing.T) {
164164
name: "no files",
165165
files: []*models.File{},
166166
expected: &Node[models.File]{
167-
Path: "",
167+
path: "",
168168
Children: []*Node[models.File]{},
169169
},
170170
},
@@ -179,16 +179,16 @@ func TestBuildFlatTreeFromFiles(t *testing.T) {
179179
},
180180
},
181181
expected: &Node[models.File]{
182-
Path: "",
182+
path: "",
183183
Children: []*Node[models.File]{
184184
{
185185
File: &models.File{Path: "dir1/a"},
186-
Path: "dir1/a",
186+
path: "dir1/a",
187187
CompressionLevel: 0,
188188
},
189189
{
190190
File: &models.File{Path: "dir1/b"},
191-
Path: "dir1/b",
191+
path: "dir1/b",
192192
CompressionLevel: 0,
193193
},
194194
},
@@ -205,16 +205,16 @@ func TestBuildFlatTreeFromFiles(t *testing.T) {
205205
},
206206
},
207207
expected: &Node[models.File]{
208-
Path: "",
208+
path: "",
209209
Children: []*Node[models.File]{
210210
{
211211
File: &models.File{Path: "dir1/a"},
212-
Path: "dir1/a",
212+
path: "dir1/a",
213213
CompressionLevel: 0,
214214
},
215215
{
216216
File: &models.File{Path: "dir2/b"},
217-
Path: "dir2/b",
217+
path: "dir2/b",
218218
CompressionLevel: 0,
219219
},
220220
},
@@ -231,15 +231,15 @@ func TestBuildFlatTreeFromFiles(t *testing.T) {
231231
},
232232
},
233233
expected: &Node[models.File]{
234-
Path: "",
234+
path: "",
235235
Children: []*Node[models.File]{
236236
{
237237
File: &models.File{Path: "a"},
238-
Path: "a",
238+
path: "a",
239239
},
240240
{
241241
File: &models.File{Path: "b"},
242-
Path: "b",
242+
path: "b",
243243
},
244244
},
245245
},
@@ -273,31 +273,31 @@ func TestBuildFlatTreeFromFiles(t *testing.T) {
273273
},
274274
},
275275
expected: &Node[models.File]{
276-
Path: "",
276+
path: "",
277277
Children: []*Node[models.File]{
278278
{
279279
File: &models.File{Path: "c1", HasMergeConflicts: true},
280-
Path: "c1",
280+
path: "c1",
281281
},
282282
{
283283
File: &models.File{Path: "c2", HasMergeConflicts: true},
284-
Path: "c2",
284+
path: "c2",
285285
},
286286
{
287287
File: &models.File{Path: "b1", Tracked: true},
288-
Path: "b1",
288+
path: "b1",
289289
},
290290
{
291291
File: &models.File{Path: "b2", Tracked: true},
292-
Path: "b2",
292+
path: "b2",
293293
},
294294
{
295295
File: &models.File{Path: "a1", Tracked: false},
296-
Path: "a1",
296+
path: "a1",
297297
},
298298
{
299299
File: &models.File{Path: "a2", Tracked: false},
300-
Path: "a2",
300+
path: "a2",
301301
},
302302
},
303303
},
@@ -322,7 +322,7 @@ func TestBuildTreeFromCommitFiles(t *testing.T) {
322322
name: "no files",
323323
files: []*models.CommitFile{},
324324
expected: &Node[models.CommitFile]{
325-
Path: "",
325+
path: "",
326326
Children: nil,
327327
},
328328
},
@@ -337,18 +337,18 @@ func TestBuildTreeFromCommitFiles(t *testing.T) {
337337
},
338338
},
339339
expected: &Node[models.CommitFile]{
340-
Path: "",
340+
path: "",
341341
Children: []*Node[models.CommitFile]{
342342
{
343-
Path: "dir1",
343+
path: "dir1",
344344
Children: []*Node[models.CommitFile]{
345345
{
346346
File: &models.CommitFile{Path: "dir1/a"},
347-
Path: "dir1/a",
347+
path: "dir1/a",
348348
},
349349
{
350350
File: &models.CommitFile{Path: "dir1/b"},
351-
Path: "dir1/b",
351+
path: "dir1/b",
352352
},
353353
},
354354
},
@@ -366,24 +366,24 @@ func TestBuildTreeFromCommitFiles(t *testing.T) {
366366
},
367367
},
368368
expected: &Node[models.CommitFile]{
369-
Path: "",
369+
path: "",
370370
Children: []*Node[models.CommitFile]{
371371
{
372-
Path: "dir1/dir3",
372+
path: "dir1/dir3",
373373
Children: []*Node[models.CommitFile]{
374374
{
375375
File: &models.CommitFile{Path: "dir1/dir3/a"},
376-
Path: "dir1/dir3/a",
376+
path: "dir1/dir3/a",
377377
},
378378
},
379379
CompressionLevel: 1,
380380
},
381381
{
382-
Path: "dir2/dir4",
382+
path: "dir2/dir4",
383383
Children: []*Node[models.CommitFile]{
384384
{
385385
File: &models.CommitFile{Path: "dir2/dir4/b"},
386-
Path: "dir2/dir4/b",
386+
path: "dir2/dir4/b",
387387
},
388388
},
389389
CompressionLevel: 1,
@@ -402,15 +402,15 @@ func TestBuildTreeFromCommitFiles(t *testing.T) {
402402
},
403403
},
404404
expected: &Node[models.CommitFile]{
405-
Path: "",
405+
path: "",
406406
Children: []*Node[models.CommitFile]{
407407
{
408408
File: &models.CommitFile{Path: "a"},
409-
Path: "a",
409+
path: "a",
410410
},
411411
{
412412
File: &models.CommitFile{Path: "b"},
413-
Path: "b",
413+
path: "b",
414414
},
415415
},
416416
},
@@ -435,7 +435,7 @@ func TestBuildFlatTreeFromCommitFiles(t *testing.T) {
435435
name: "no files",
436436
files: []*models.CommitFile{},
437437
expected: &Node[models.CommitFile]{
438-
Path: "",
438+
path: "",
439439
Children: []*Node[models.CommitFile]{},
440440
},
441441
},
@@ -450,16 +450,16 @@ func TestBuildFlatTreeFromCommitFiles(t *testing.T) {
450450
},
451451
},
452452
expected: &Node[models.CommitFile]{
453-
Path: "",
453+
path: "",
454454
Children: []*Node[models.CommitFile]{
455455
{
456456
File: &models.CommitFile{Path: "dir1/a"},
457-
Path: "dir1/a",
457+
path: "dir1/a",
458458
CompressionLevel: 0,
459459
},
460460
{
461461
File: &models.CommitFile{Path: "dir1/b"},
462-
Path: "dir1/b",
462+
path: "dir1/b",
463463
CompressionLevel: 0,
464464
},
465465
},
@@ -476,16 +476,16 @@ func TestBuildFlatTreeFromCommitFiles(t *testing.T) {
476476
},
477477
},
478478
expected: &Node[models.CommitFile]{
479-
Path: "",
479+
path: "",
480480
Children: []*Node[models.CommitFile]{
481481
{
482482
File: &models.CommitFile{Path: "dir1/a"},
483-
Path: "dir1/a",
483+
path: "dir1/a",
484484
CompressionLevel: 0,
485485
},
486486
{
487487
File: &models.CommitFile{Path: "dir2/b"},
488-
Path: "dir2/b",
488+
path: "dir2/b",
489489
CompressionLevel: 0,
490490
},
491491
},
@@ -502,15 +502,15 @@ func TestBuildFlatTreeFromCommitFiles(t *testing.T) {
502502
},
503503
},
504504
expected: &Node[models.CommitFile]{
505-
Path: "",
505+
path: "",
506506
Children: []*Node[models.CommitFile]{
507507
{
508508
File: &models.CommitFile{Path: "a"},
509-
Path: "a",
509+
path: "a",
510510
},
511511
{
512512
File: &models.CommitFile{Path: "b"},
513-
Path: "b",
513+
path: "b",
514514
},
515515
},
516516
},

pkg/gui/filetree/commit_file_tree.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type CommitFileTree struct {
2727

2828
func (self *CommitFileTree) CollapseAll() {
2929
dirPaths := lo.FilterMap(self.GetAllItems(), func(file *CommitFileNode, index int) (string, bool) {
30-
return file.Path, !file.IsFile()
30+
return file.path, !file.IsFile()
3131
})
3232

3333
for _, path := range dirPaths {

0 commit comments

Comments
 (0)