Skip to content

Commit

Permalink
Project package should not reference the localcommit package.
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchell-as committed Oct 19, 2023
1 parent 312e01a commit b700527
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
4 changes: 2 additions & 2 deletions internal/runbits/commitmediator/commitmediator.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ type projecter interface {
LegacyCommitID() string
}

// GetCompatible returns the given project's commit ID in either the new format (commit file), or
// the old format (activestate.yaml).
// Get returns the given project's commit ID in either the new format (commit file), or the old
// format (activestate.yaml).
// If you require the commit file, use localcommit.Get().
func Get(proj projecter, prompter prompt.Prompter, out output.Outputer) (strfmt.UUID, error) {
if commitID, err := localcommit.Get(proj.Dir()); err == nil {
Expand Down
14 changes: 2 additions & 12 deletions pkg/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/ActiveState/cli/internal/osutils"
"github.com/ActiveState/cli/internal/output"
"github.com/ActiveState/cli/internal/prompt"
"github.com/ActiveState/cli/pkg/localcommit"
secretsapi "github.com/ActiveState/cli/pkg/platform/api/secrets"
"github.com/ActiveState/cli/pkg/platform/authentication"
"github.com/ActiveState/cli/pkg/projectfile"
Expand Down Expand Up @@ -259,17 +258,8 @@ func (p *Project) Cache() string { return p.projectfile.Cache }

// Namespace returns project namespace
func (p *Project) Namespace() *Namespaced {
commitID, err := localcommit.Get(p.Dir())
if err != nil {
if !localcommit.IsFileDoesNotExistError(err) {
// Note: cannot use commitmediator.Get() because this is called by main before analytics
// and a prompt and output are set up.
commitID = strfmt.UUID(p.projectfile.LegacyCommitID())
} else {
multilog.Error("Unable to get local commit: %v", errs.JoinMessage(err))
}
}
return &Namespaced{p.projectfile.Owner(), p.projectfile.Name(), &commitID, false}
commitId := strfmt.UUID(p.projectfile.LegacyCommitID())
return &Namespaced{p.projectfile.Owner(), p.projectfile.Name(), &commitId, false}
}

// NamespaceString is a convenience function to make interfaces simpler
Expand Down
2 changes: 1 addition & 1 deletion pkg/project/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (suite *ProjectTestSuite) BeforeTest(suiteName, testName string) {

cfg, err := config.New()
suite.Require().NoError(err)
project.RegisterConditional(constraints.NewPrimeConditional(nil, suite.project, subshell.New(cfg).Shell()), nil, nil)
project.RegisterConditional(constraints.NewPrimeConditional(nil, suite.project, subshell.New(cfg).Shell(), nil, nil))
}

func (suite *ProjectTestSuite) TestGet() {
Expand Down

0 comments on commit b700527

Please sign in to comment.