Skip to content

Commit a0f7ddb

Browse files
committed
Fix label diff to respect --color flag
1 parent e7c960e commit a0f7ddb

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

internal/engine/apply/apply.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func Diff(local, upstream GmailConfig, debugInfo bool, contextLines int, allowCo
129129

130130
if len(local.Labels) > 0 {
131131
// LabelsDiff management opted-in
132-
res.LabelsDiff, err = label.Diff(upstream.Labels, local.Labels)
132+
res.LabelsDiff, err = label.Diff(upstream.Labels, local.Labels, allowColor)
133133
if err != nil {
134134
return res, fmt.Errorf("cannot compute labels diff: %w", err)
135135
}

internal/engine/label/diff.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import (
1414
//
1515
// To compute the diff, IDs are ignored, only the properties of the labels are
1616
// actually considered.
17-
func Diff(upstream, local Labels) (LabelsDiff, error) {
17+
func Diff(upstream, local Labels, allowColor bool) (LabelsDiff, error) {
1818
sort.Sort(byName(upstream))
1919
sort.Sort(byName(local))
2020

21-
res := LabelsDiff{}
21+
res := LabelsDiff{AllowColor: allowColor}
2222
i, j := 0, 0
2323

2424
for i < len(upstream) && j < len(local) {
@@ -63,9 +63,10 @@ func Diff(upstream, local Labels) (LabelsDiff, error) {
6363

6464
// LabelsDiff contains the diff of two lists of labels.
6565
type LabelsDiff struct {
66-
Modified []ModifiedLabel
67-
Added Labels
68-
Removed Labels
66+
Modified []ModifiedLabel
67+
Added Labels
68+
Removed Labels
69+
AllowColor bool
6970
}
7071

7172
// Empty returns true if the diff is empty.
@@ -103,7 +104,7 @@ func (d LabelsDiff) String() string {
103104
FromFile: "Current",
104105
ToFile: "TO BE APPLIED",
105106
Context: 3,
106-
Color: true,
107+
Color: d.AllowColor,
107108
})
108109
if err != nil {
109110
// We can't get a diff apparently, let's make something up here

0 commit comments

Comments
 (0)