Skip to content

Commit

Permalink
fix(cli-client): empty directories cause CI validation error (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdcordeiro authored Oct 24, 2024
1 parent 9fc2f8d commit 8bd95de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion tools/cli-client/internals/trigger/build_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ func InferBuildMetadata() BuildMetadata {
logger.Panicf("Subprocess `git rev-parse --show-prefix` failed: %v", err)
}
// remote the trailing newline
prefix := strings.TrimSpace(string(prefixBytes))
// also prepend a "./" to cope with empty prefixes
prefix := "./" + strings.TrimSpace(string(prefixBytes))
logger.Debugf("Directory: %s", prefix)

buildMetadata := BuildMetadata{
Expand Down
4 changes: 2 additions & 2 deletions tools/cli-client/internals/trigger/build_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (s *BuildMetadataSuite) TestGetRockcraftYamlName(c *C) {
c.Assert(result, Equals, expected)
}

func (s *BuildMetadataSuite) TestGetBuildMetadataCustomDirector(c *C) {
func (s *BuildMetadataSuite) TestGetBuildMetadataCustomDirectory(c *C) {
cmd := exec.Command("git", "--version")
if err := cmd.Run(); err != nil {
c.Fatal("git not installed")
Expand All @@ -52,7 +52,7 @@ func (s *BuildMetadataSuite) TestGetBuildMetadataCustomDirector(c *C) {

result := trigger.InferBuildMetadata()

prefix := filepath.Join("mock_rock", "1.0") + "/"
prefix := "./" + filepath.Join("mock_rock", "1.0") + "/"
head, err := exec.Command("git", "rev-parse", "HEAD").Output()
headStr := strings.TrimSpace(string(head))
c.Assert(err, IsNil)
Expand Down

0 comments on commit 8bd95de

Please # to comment.