From 2bcee536e144533c6c7a9175dc00c131df8ef91d Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Wed, 13 Jan 2021 19:49:43 -0500 Subject: [PATCH] Promote git metadata functionality from experimental to stable This reverts commit 5244a13a48bcc8ee64e05ce7f0f2996e4ff5a77f. --- cmd/submit.go | 5 ++--- cmd/submit_test.go | 1 - metadata/metadata.go | 31 +++++++++---------------------- 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/cmd/submit.go b/cmd/submit.go index 0f8c2a8d..d9440a27 100644 --- a/cmd/submit.go +++ b/cmd/submit.go @@ -101,12 +101,11 @@ func (s *Submit) Init(args []string, envs map[string]string) error { info, err = os.Stat(s.repositoryPath) if err != nil || !info.IsDir() { - return fmt.Errorf("[experimental] invalid value for flag -repository-dir: %s is not a directory", s.repositoryPath) + return fmt.Errorf("invalid value for flag -repository-dir: %s is not a directory", s.repositoryPath) } s.commitResolver, err = metadata.NewCommitResolver(s.repositoryPath) if err != nil { - // Git metadata functionality is experimental. While it's experimental, don't let an invalid repository prevent the test-reporter from continuing normal operation. - fmt.Fprintf(os.Stderr, "[experimental] invalid value for flag -repository-dir: %v\n", err) + return fmt.Errorf("invalid value for flag -repository-dir: %v", err) } s.envs = envs diff --git a/cmd/submit_test.go b/cmd/submit_test.go index 8f53d4c4..efa92e73 100644 --- a/cmd/submit_test.go +++ b/cmd/submit_test.go @@ -176,7 +176,6 @@ func TestSubmit_Init_invalidPath(t *testing.T) { func TestSubmit_Init_invalidRepoPath(t *testing.T) { t.Run("NonRepoPath", func(t *testing.T) { - t.Skip("skipping while git metadata functionality is experimental") s := NewSubmit(&metadata.Version{}) err := s.Init([]string{ ".", diff --git a/metadata/metadata.go b/metadata/metadata.go index fb35986f..7244da50 100644 --- a/metadata/metadata.go +++ b/metadata/metadata.go @@ -2,7 +2,6 @@ package metadata import ( "fmt" - "os" "regexp" "strconv" "strings" @@ -26,41 +25,29 @@ type Metadata interface { // AbstractMetadata provides the fields that are common across all Metadata // instances, regardless of the specific CI provider. type AbstractMetadata struct { - AuthoredAt time.Time `yaml:":authored_at,omitempty"` - AuthorEmail string `yaml:":author_email,omitempty"` - AuthorName string `yaml:":author_name,omitempty"` + AuthoredAt time.Time `yaml:":authored_at"` + AuthorEmail string `yaml:":author_email"` + AuthorName string `yaml:":author_name"` Branch string `yaml:":branch"` BuildURL string `yaml:":build_url"` Check string `yaml:":check" env:"BUILDPULSE_CHECK_NAME"` CIProvider string `yaml:":ci_provider"` - CommitMessage string `yaml:":commit_message,omitempty"` + CommitMessage string `yaml:":commit_message"` CommitSHA string `yaml:":commit"` - CommittedAt time.Time `yaml:":committed_at,omitempty"` - CommitterEmail string `yaml:":committer_email,omitempty"` - CommitterName string `yaml:":committer_name,omitempty"` + CommittedAt time.Time `yaml:":committed_at"` + CommitterEmail string `yaml:":committer_email"` + CommitterName string `yaml:":committer_name"` RepoNameWithOwner string `yaml:":repo_name_with_owner"` ReporterOS string `yaml:":reporter_os"` ReporterVersion string `yaml:":reporter_version"` Timestamp time.Time `yaml:":timestamp"` - TreeSHA string `yaml:":tree,omitempty"` + TreeSHA string `yaml:":tree"` } func (a *AbstractMetadata) initCommitData(cr CommitResolver, sha string) error { - // Git metadata functionality is experimental. While it's experimental, detect a nil CommitResolver and allow the commit metadata fields to be uploaded with empty values. - if cr == nil { - fmt.Fprintf(os.Stderr, "[experimental] no commit resolver available; falling back to commit data from environment\n") - - a.CommitSHA = sha - return nil - } - - // Git metadata functionality is experimental. While it's experimental, don't let this error prevent the test-reporter from continuing normal operation. Allow the commit metadata fields to be uploaded with empty values. c, err := cr.Lookup(sha) if err != nil { - fmt.Fprintf(os.Stderr, "[experimental] git-based commit lookup unsuccessful; falling back to commit data from environment: %v\n", err) - - a.CommitSHA = sha - return nil + return err } a.AuthoredAt = c.AuthoredAt