From 31c066e8aca9be23bc7e24a500219f1d7c962b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Nevrlka?= Date: Mon, 18 Mar 2024 16:53:26 +0100 Subject: [PATCH] fix: estimate review time unknown file extension edge case (#115) * fix: overshadowed variable estimate Fix variable estimate not getting set correctly if the file extension is unknown * fix: edge case when estimated time is 0 seconds Fix label not getting set correctly when estimated time is 0 seconds --- cmd/estimate/reviewTime.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/estimate/reviewTime.go b/cmd/estimate/reviewTime.go index e86da53..88d5328 100644 --- a/cmd/estimate/reviewTime.go +++ b/cmd/estimate/reviewTime.go @@ -166,7 +166,8 @@ func estimateFileTimes(files []*github.CommitFile) int { } estimate, included := config.Extensions[extension] if !included { - estimate, defaultIncluded := config.Extensions["default"] + var defaultIncluded bool + estimate, defaultIncluded = config.Extensions["default"] if !defaultIncluded { estimate = defaultExtensionWeight } @@ -228,7 +229,7 @@ func getLabelBasedOnTime(reviewTime int) (*TimeLabel, error) { } maxLabel := TimeLabel{Time: -1} for _, label := range config.Labels { - if label.Time < reviewTime && label.Time > maxLabel.Time { + if label.Time <= reviewTime && label.Time > maxLabel.Time { maxLabel = label } }