Skip to content

Commit ad1b446

Browse files
committed
[fix] Checking parsed info prior export logic
1 parent 1e2d368 commit ad1b446

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

cmd/export.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,16 +164,28 @@ func generateTextReports(granularity string, input string) (err error, report Te
164164
s = strings.TrimSpace(ns[1])
165165
// read flat%
166166
ns = strings.SplitN(s, " ", 2)
167+
if len(ns) < 2 {
168+
continue
169+
}
167170
flatPercent := ns[0]
168171
s = strings.TrimSpace(ns[1])
169172
// ignore sum
170173
ns = strings.SplitN(s, " ", 2)
174+
if len(ns) < 2 {
175+
continue
176+
}
171177
s = strings.TrimSpace(ns[1])
172178
// ignore cum
173179
ns = strings.SplitN(s, " ", 2)
180+
if len(ns) < 2 {
181+
continue
182+
}
174183
s = strings.TrimSpace(ns[1])
175184
// read cum%
176185
ns = strings.SplitN(s, " ", 2)
186+
if len(ns) < 2 {
187+
continue
188+
}
177189
cumPercent := ns[0]
178190
symbol := strings.TrimSpace(ns[1])
179191
report.Items = append(report.Items, TextItem{

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func init() {
7777
repoStartPos := strings.LastIndex(remoteUsed, "/") + 1
7878
defaultGitRepo = remoteUsed[repoStartPos : len(remoteUsed)-4]
7979
defaultGitCommit = refHash
80-
fmt.Println("Detected the following git vars org=%s repo=%s hash=%s", defaultGitOrg, defaultGitRepo, defaultGitCommit)
80+
fmt.Printf("Detected the following git vars org=%s repo=%s hash=%s", defaultGitOrg, defaultGitRepo, defaultGitCommit)
8181
}
8282

8383
// Here you will define your flags and configuration settings.

0 commit comments

Comments
 (0)