Skip to content

Commit a394e8a

Browse files
committed
Introduce method HistorySize.JSON()
Use it instead of `JSONString()`.
1 parent 67be11d commit a394e8a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

git-sizer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func mainImplementation() error {
166166
}
167167

168168
if jsonOutput {
169-
j, err := sizes.JSONString(historySize.Contents(), threshold, nameStyle)
169+
j, err := historySize.JSON(threshold, nameStyle)
170170
if err != nil {
171171
return fmt.Errorf("could not convert %v to json: %s", historySize, err)
172172
}

sizes/output.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,12 @@ func (t *table) formatRow(
421421
)
422422
}
423423

424-
func JSONString(contents tableContents, threshold Threshold, nameStyle NameStyle) (string, error) {
424+
func (s HistorySize) JSON(threshold Threshold, nameStyle NameStyle) ([]byte, error) {
425+
contents := s.Contents()
425426
items := make(map[string]*item)
426427
contents.CollectItems(items)
427428
j, err := json.MarshalIndent(items, "", " ")
428-
return string(j), err
429+
return j, err
429430
}
430431

431432
func (s HistorySize) Contents() tableContents {

0 commit comments

Comments
 (0)