From ea2f3390a076ce93c114c1930e830f5ccb9394cc Mon Sep 17 00:00:00 2001 From: nixargh Date: Thu, 3 Aug 2023 19:03:14 +0300 Subject: [PATCH] v1.0.2 skip unfinished lines --- .gitignore | 2 +- CHANGELOG.md | 4 ++++ main.go | 8 +++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 14e10bf..4bfc4f7 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,7 @@ # vendor/ # compiled binary -roly-poly-vpn +tired # vim *.sw? diff --git a/CHANGELOG.md b/CHANGELOG.md index 8147d0e..de2fe93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [1.0.2] - 2023-08-03 +### Fixed +- Skip unfinished lines. + ## [1.0.1] - 2023-08-02 ### Fixed - Don't split comment with `,` sign. diff --git a/main.go b/main.go index 143afc6..b549c8c 100644 --- a/main.go +++ b/main.go @@ -20,7 +20,7 @@ import ( // "github.com/pkg/profile" ) -var version string = "1.0.1" +var version string = "1.0.2" var clog *log.Entry @@ -265,6 +265,12 @@ func parseWorkRecords(records []string) []WorkRecord { wr.Issue = fields[3] wr.Comment = strings.ReplaceAll(fields[4], "\"", "") + // Validations + if wr.Date == "" || wr.StartTime == "" || wr.EndTime == "" || wr.Issue == "" || wr.Comment == "" { + clog.WithFields(log.Fields{"record": wr}).Warning("Some fields are empty, skipping the record.") + continue + } + // Add duration startDateTimeString := fmt.Sprintf("%s %s:00", wr.Date, wr.StartTime) startDateTime, serr := time.ParseInLocation(time.DateTime, startDateTimeString, location)