Skip to content

Commit 4932aff

Browse files
Fixing repo directory value trimming when pkg name contains it (#289)
* fixing repo directory value trimming when pkg name contains it * adding trimPrefix for absolute vs relative path in initial discovery of pkgs * adding comment to explain change * comment change to retrigger test
1 parent d7254b6 commit 4932aff

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

pkg/externalrepo/git/package_tree.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"encoding/json"
2020
"fmt"
2121
"path"
22+
"strings"
2223
"time"
2324

2425
"github.com/go-git/go-git/v5/plumbing"
@@ -154,7 +155,8 @@ func (t *packageList) discoverPackages(repoKey repository.RepositoryKey, tree *o
154155

155156
// Found a package
156157
t.packages[treePath] = &packageListEntry{
157-
pkgKey: repository.FromFullPathname(repoKey, treePath),
158+
// When discovering packages the absolute path of the package is needed in relation to the root of the repo
159+
pkgKey: repository.FromFullPathname(repoKey, strings.TrimPrefix(treePath, repoKey.Path)),
158160
treeHash: tree.Hash,
159161
parent: t,
160162
}

pkg/repository/repository.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func K8SName2PkgName(k8sName string) string {
160160
}
161161

162162
func FromFullPathname(repoKey RepositoryKey, fullpath string) PackageKey {
163-
pkgPath := strings.Trim(strings.TrimPrefix(fullpath, repoKey.Path), "/")
163+
pkgPath := strings.Trim(fullpath, "/")
164164
slashIndex := strings.LastIndex(pkgPath, "/")
165165

166166
if slashIndex >= 0 {

0 commit comments

Comments
 (0)