diff --git a/tools/cli-client/internals/trigger/build_metadata.go b/tools/cli-client/internals/trigger/build_metadata.go index 50cec384..377f0107 100644 --- a/tools/cli-client/internals/trigger/build_metadata.go +++ b/tools/cli-client/internals/trigger/build_metadata.go @@ -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{ diff --git a/tools/cli-client/internals/trigger/build_metadata_test.go b/tools/cli-client/internals/trigger/build_metadata_test.go index f228eb23..3285364c 100644 --- a/tools/cli-client/internals/trigger/build_metadata_test.go +++ b/tools/cli-client/internals/trigger/build_metadata_test.go @@ -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") @@ -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)