Skip to content

Commit

Permalink
Promote git metadata functionality from experimental to stable
Browse files Browse the repository at this point in the history
This reverts commit 5244a13.
  • Loading branch information
jasonrudolph committed Jan 14, 2021
1 parent 4503150 commit 2bcee53
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 26 deletions.
5 changes: 2 additions & 3 deletions cmd/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion cmd/submit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
".",
Expand Down
31 changes: 9 additions & 22 deletions metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package metadata

import (
"fmt"
"os"
"regexp"
"strconv"
"strings"
Expand All @@ -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
Expand Down

0 comments on commit 2bcee53

Please sign in to comment.