From 4e0c42a3753db3cc11641a2a81d54a7ddf2d4aaf Mon Sep 17 00:00:00 2001 From: Eran Turgeman Date: Thu, 5 Oct 2023 11:10:33 +0300 Subject: [PATCH 1/2] fixing the check for isDirectDependency to iterate over all provided paths and not just the first entry --- utils/utils.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/utils/utils.go b/utils/utils.go index 15013017d..3be8c3f83 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -314,7 +314,15 @@ func IsDirectDependency(impactPath [][]formats.ComponentRow) (bool, error) { if len(impactPath) == 0 { return false, fmt.Errorf("invalid impact path provided") } - return len(impactPath[0]) < 3, nil + + for _, path := range impactPath { + // Impacted path always starts with the name of the project's directory and ends with the impacted package. + // Therefore if the length of the path is less than 2 it means the dependency is a direct one + if len(path) < 3 { + return true, nil + } + } + return false, nil } func validateBranchName(branchName string) error { From 01a1b240b8cdcaae56ff504b6b45c3d97a2f09ee Mon Sep 17 00:00:00 2001 From: Eran Turgeman Date: Wed, 18 Oct 2023 18:09:59 +0300 Subject: [PATCH 2/2] minor fix --- utils/utils.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/utils.go b/utils/utils.go index 2d20afc67..c1a122764 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -310,15 +310,15 @@ func GetRelativeWd(fullPathWd, baseWd string) string { } // The impact graph of direct dependencies consists of only two elements. -func IsDirectDependency(impactPath [][]formats.ComponentRow) (bool, error) { - if len(impactPath) == 0 { +func IsDirectDependency(impactPathList [][]formats.ComponentRow) (bool, error) { + if len(impactPathList) == 0 { return false, fmt.Errorf("invalid impact path provided") } - for _, path := range impactPath { + for _, impactPath := range impactPathList { // Impacted path always starts with the name of the project's directory and ends with the impacted package. // Therefore if the length of the path is less than 2 it means the dependency is a direct one - if len(path) < 3 { + if len(impactPath) < 3 { return true, nil } }