Skip to content

Commit

Permalink
pkg: refactor out scorecard_version
Browse files Browse the repository at this point in the history
  • Loading branch information
06kellyjac authored and naveensrinivasan committed May 10, 2022
1 parent 62e3de5 commit c5d787a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 94 deletions.
4 changes: 2 additions & 2 deletions cron/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import (

"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/types/known/timestamppb"
"sigs.k8s.io/release-utils/version"

"github.com/ossf/scorecard/v4/clients"
"github.com/ossf/scorecard/v4/cron/config"
"github.com/ossf/scorecard/v4/cron/data"
"github.com/ossf/scorecard/v4/cron/pubsub"
"github.com/ossf/scorecard/v4/pkg"
)

var headSHA = clients.HeadSHA
Expand Down Expand Up @@ -140,7 +140,7 @@ func main() {
}
*metadata.NumShard = (shardNum + 1)
*metadata.ShardLoc = bucket + "/" + data.GetBlobFilename("", t)
*metadata.CommitSha = pkg.GetCommit()
*metadata.CommitSha = version.GetVersionInfo().GitCommit
metadataJSON, err := protojson.Marshal(&metadata)
if err != nil {
panic(fmt.Errorf("error during protojson.Marshal: %w", err))
Expand Down
8 changes: 5 additions & 3 deletions pkg/scorecard.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"sync"
"time"

"sigs.k8s.io/release-utils/version"

"github.com/ossf/scorecard/v4/checker"
"github.com/ossf/scorecard/v4/clients"
sce "github.com/ossf/scorecard/v4/errors"
Expand Down Expand Up @@ -96,15 +98,15 @@ func RunScorecards(ctx context.Context,
if err != nil {
return ScorecardResult{}, err
}

versionInfo := version.GetVersionInfo()
ret := ScorecardResult{
Repo: RepoInfo{
Name: repo.URI(),
CommitSHA: commitSHA,
},
Scorecard: ScorecardInfo{
Version: GetSemanticVersion(),
CommitSHA: GetCommit(),
Version: versionInfo.GitVersion,
CommitSHA: versionInfo.GitCommit,
},
Date: time.Now(),
}
Expand Down
87 changes: 0 additions & 87 deletions pkg/scorecard_version.go

This file was deleted.

4 changes: 2 additions & 2 deletions scripts/version-ldflags
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ GIT_HASH=$(git rev-parse HEAD)
# https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git-log.html
SOURCE_DATE_EPOCH=$(git log --date=iso8601-strict -1 --pretty=%ct)
GIT_TREESTATE=$(if git diff --quiet; then echo "clean"; else echo "dirty"; fi)
PKG=$(go list -m | head -n1)/pkg
echo "-X $PKG.gitVersion=$GIT_VERSION -X $PKG.gitCommit=$GIT_HASH -X $PKG.gitTreeState=$GIT_TREESTATE -X $PKG.buildDate=$SOURCE_DATE_EPOCH -w -extldflags \"-static\""
PKG=sigs.k8s.io/release-utils/version
echo "-X $PKG.gitVersion=$GIT_VERSION -X $PKG.gitCommit=$GIT_HASH -X $PKG.gitTreeState=$GIT_TREESTATE -X $PKG.buildDate=$SOURCE_DATE_EPOCH -w -extldflags \"-static\""

0 comments on commit c5d787a

Please sign in to comment.