Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporarily disable localcommit files and buildscripts. #2853

Merged
merged 10 commits into from
Nov 2, 2023
2 changes: 1 addition & 1 deletion cmd/state/internal/cmdtree/cmdtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func New(prime *primer.Values, args ...string) *CmdTree {
refreshCmd,
newSwitchCommand(prime),
newTestCommand(prime),
newCommitCommand(prime),
//newCommitCommand(prime), // re-enable in DX-2307
)

return &CmdTree{
Expand Down
3 changes: 2 additions & 1 deletion internal/constraints/constraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ type projectable interface {
Path() string
Dir() string
URL() string
LegacyCommitID() string // for commitmediator.Get
LegacyCommitID() string // for commitmediator.Get
LegacySetCommit(string) error // for commitmediator.Set; remove in DX-2307
}

func NewPrimeConditional(auth *authentication.Auth, pj projectable, subshellName string) *Conditional {
Expand Down
35 changes: 20 additions & 15 deletions internal/runbits/commitmediator/commitmediator.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package commitmediator

import (
"github.com/ActiveState/cli/internal/errs"
"github.com/ActiveState/cli/internal/runbits/legacy/projectmigration"
"github.com/ActiveState/cli/pkg/localcommit"
"github.com/go-openapi/strfmt"
)

Expand All @@ -12,22 +9,30 @@ type projecter interface {
URL() string
Path() string
LegacyCommitID() string
LegacySetCommit(string) error // remove this in DX-2307
}

// 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) (strfmt.UUID, error) {
if commitID, err := localcommit.Get(proj.Dir()); err == nil {
return commitID, nil
} else if localcommit.IsFileDoesNotExistError(err) {
if migrated, err := projectmigration.PromptAndMigrate(proj); err == nil && migrated {
return localcommit.Get(proj.Dir())
} else if err != nil {
return "", errs.Wrap(err, "Could not prompt and/or migrate project")
}
return strfmt.UUID(proj.LegacyCommitID()), nil
} else {
return "", errs.Wrap(err, "Could not get local commit")
}
// Re-enable the contents of this function in DX-2307
//if commitID, err := localcommit.Get(proj.Dir()); err == nil {
// return commitID, nil
//} else if localcommit.IsFileDoesNotExistError(err) {
//if migrated, err := projectmigration.PromptAndMigrate(proj); err == nil && migrated {
// return localcommit.Get(proj.Dir())
//} else if err != nil {
// return "", errs.Wrap(err, "Could not prompt and/or migrate project")
//}
return strfmt.UUID(proj.LegacyCommitID()), nil
//} else {
// return "", errs.Wrap(err, "Could not get local commit")
//}
}

func Set(proj projecter, commitID string) error {
// Replace all calls to this function with localcommit.Set() in DX-2307.
// Also, consider changing localcommit.Set() to accept a projecter interface with Dir().
return proj.LegacySetCommit(commitID)
}
10 changes: 5 additions & 5 deletions internal/runbits/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/ActiveState/cli/internal/locale"
"github.com/ActiveState/cli/internal/output"
"github.com/ActiveState/cli/internal/rtutils"
"github.com/ActiveState/cli/internal/runbits/buildscript"
"github.com/ActiveState/cli/pkg/platform/authentication"
"github.com/ActiveState/cli/pkg/platform/model"
"github.com/ActiveState/cli/pkg/platform/runtime"
Expand All @@ -25,10 +24,11 @@ func RefreshRuntime(
trigger target.Trigger,
svcm *model.SvcModel,
) (rerr error) {
_, err := buildscript.Sync(proj, &commitID, out, auth)
if err != nil {
return locale.WrapError(err, "err_update_build_script")
}
// Re-enable in DX-2307.
//_, err := buildscript.Sync(proj, &commitID, out, auth)
//if err != nil {
// return locale.WrapError(err, "err_update_build_script")
//}
target := target.NewProjectTarget(proj, nil, trigger)
isCached := true
rt, err := runtime.New(target, an, svcm, auth)
Expand Down
27 changes: 14 additions & 13 deletions internal/runbits/requirements/requirements.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ import (
"github.com/ActiveState/cli/internal/prompt"
"github.com/ActiveState/cli/internal/rtutils/ptr"
"github.com/ActiveState/cli/internal/runbits"
"github.com/ActiveState/cli/internal/runbits/commitmediator"
"github.com/ActiveState/cli/internal/runbits/rationalize"
"github.com/ActiveState/cli/pkg/localcommit"
bpModel "github.com/ActiveState/cli/pkg/platform/api/buildplanner/model"
medmodel "github.com/ActiveState/cli/pkg/platform/api/mediator/model"
"github.com/ActiveState/cli/pkg/platform/authentication"
"github.com/ActiveState/cli/pkg/platform/model"
"github.com/ActiveState/cli/pkg/platform/runtime/buildscript"
"github.com/ActiveState/cli/pkg/platform/runtime/target"
"github.com/ActiveState/cli/pkg/project"
"github.com/thoas/go-funk"
Expand Down Expand Up @@ -108,7 +107,7 @@ func (r *RequirementOperation) ExecuteRequirementOperation(requirementName, requ

switch nsType {
case model.NamespacePackage, model.NamespaceBundle:
commitID, err := localcommit.Get(r.Project.Dir())
commitID, err := commitmediator.Get(r.Project)
if err != nil {
return errs.Wrap(err, "Unable to get local commit")
}
Expand Down Expand Up @@ -190,7 +189,7 @@ func (r *RequirementOperation) ExecuteRequirementOperation(requirementName, requ
pg = nil
}

parentCommitID, err := localcommit.Get(r.Project.Dir())
parentCommitID, err := commitmediator.Get(r.Project)
if err != nil {
return errs.Wrap(err, "Unable to get local commit")
}
Expand Down Expand Up @@ -269,20 +268,22 @@ func (r *RequirementOperation) ExecuteRequirementOperation(requirementName, requ
return errs.Wrap(err, "Unsupported namespace type: %s", ns.Type().String())
}

expr, err := bp.GetBuildExpression(r.Project.Owner(), r.Project.Name(), commitID.String())
if err != nil {
return errs.Wrap(err, "Could not get remote build expr")
}
// Re-enable in DX-2307.
//expr, err := bp.GetBuildExpression(r.Project.Owner(), r.Project.Name(), commitID.String())
//if err != nil {
// return errs.Wrap(err, "Could not get remote build expr")
//}

if err := localcommit.Set(r.Project.Dir(), commitID.String()); err != nil {
if err := commitmediator.Set(r.Project, commitID.String()); err != nil {
return locale.WrapError(err, "err_package_update_commit_id")
}

// Note: a commit ID file needs to exist at this point.
err = buildscript.Update(r.Project, expr, r.Auth)
if err != nil {
return locale.WrapError(err, "err_update_build_script")
}
// Re-enable in DX-2307.
//err = buildscript.Update(r.Project, expr, r.Auth)
//if err != nil {
// return locale.WrapError(err, "err_update_build_script")
//}

// refresh or install runtime
err = runbits.RefreshRuntime(r.Auth, r.Output, r.Analytics, r.Project, commitID, true, trigger, r.SvcModel)
Expand Down
4 changes: 2 additions & 2 deletions internal/runners/branch/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/ActiveState/cli/internal/locale"
"github.com/ActiveState/cli/internal/logging"
"github.com/ActiveState/cli/internal/output"
"github.com/ActiveState/cli/pkg/localcommit"
"github.com/ActiveState/cli/internal/runbits/commitmediator"
"github.com/ActiveState/cli/pkg/platform/model"
"github.com/ActiveState/cli/pkg/project"
)
Expand Down Expand Up @@ -49,7 +49,7 @@ func (a *Add) Run(params AddParams) error {
return locale.WrapError(err, "err_fetch_branch", "", localBranch)
}

commitID, err := localcommit.Get(a.project.Dir())
commitID, err := commitmediator.Get(a.project)
if err != nil {
return errs.Wrap(err, "Unable to get local commit")
}
Expand Down
27 changes: 14 additions & 13 deletions internal/runners/initialize/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/ActiveState/cli/internal/primer"
"github.com/ActiveState/cli/internal/runbits"
"github.com/ActiveState/cli/internal/runbits/commitmediator"
"github.com/ActiveState/cli/pkg/localcommit"
"github.com/ActiveState/cli/pkg/platform/authentication"
"github.com/ActiveState/cli/pkg/platform/model"
"github.com/ActiveState/cli/pkg/platform/runtime/setup"
Expand Down Expand Up @@ -157,10 +156,11 @@ func (r *Initialize) Run(params *RunParams) (rerr error) {
}
}

emptyDir, err := fileutils.IsEmptyDir(path)
if err != nil {
multilog.Error("Unable to check if directory is empty: %v", err)
}
// Re-enable in DX-2307.
//emptyDir, err := fileutils.IsEmptyDir(path)
//if err != nil {
// multilog.Error("Unable to check if directory is empty: %v", err)
//}

// Match the case of the organization.
// Otherwise the incorrect case will be written to the project file.
Expand Down Expand Up @@ -247,16 +247,17 @@ func (r *Initialize) Run(params *RunParams) (rerr error) {
return locale.WrapError(err, "err_init_commit", "Could not create initial commit")
}

if err := localcommit.Set(proj.Dir(), commitID.String()); err != nil {
if err := commitmediator.Set(proj, commitID.String()); err != nil {
return errs.Wrap(err, "Unable to create local commit file")
}
if emptyDir || fileutils.DirExists(filepath.Join(path, ".git")) {
err := localcommit.AddToGitIgnore(path)
if err != nil {
r.out.Notice(locale.Tr("notice_commit_id_gitignore", constants.ProjectConfigDirName, constants.CommitIdFileName))
multilog.Error("Unable to add local commit file to .gitignore: %v", err)
}
}
// Re-enable in DX-2307.
//if emptyDir || fileutils.DirExists(filepath.Join(path, ".git")) {
// err := localcommit.AddToGitIgnore(path)
// if err != nil {
// r.out.Notice(locale.Tr("notice_commit_id_gitignore", constants.ProjectConfigDirName, constants.CommitIdFileName))
// multilog.Error("Unable to add local commit file to .gitignore: %v", err)
// }
//}

err = runbits.RefreshRuntime(r.auth, r.out, r.analytics, proj, commitID, true, target.TriggerInit, r.svcModel)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/runners/packages/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/ActiveState/cli/internal/primer"
"github.com/ActiveState/cli/internal/prompt"
"github.com/ActiveState/cli/internal/runbits"
"github.com/ActiveState/cli/pkg/localcommit"
"github.com/ActiveState/cli/internal/runbits/commitmediator"
"github.com/ActiveState/cli/pkg/platform/api"
gqlModel "github.com/ActiveState/cli/pkg/platform/api/graphql/model"
"github.com/ActiveState/cli/pkg/platform/api/reqsimport"
Expand Down Expand Up @@ -177,7 +177,7 @@ func fetchImportChangeset(cp ChangesetProvider, file string, lang string) (model
}

func commitChangeset(project *project.Project, msg string, changeset model.Changeset) (strfmt.UUID, error) {
localCommitID, err := localcommit.Get(project.Dir())
localCommitID, err := commitmediator.Get(project)
if err != nil {
return "", errs.Wrap(err, "Unable to get local commit")
}
Expand All @@ -188,7 +188,7 @@ func commitChangeset(project *project.Project, msg string, changeset model.Chang
locale.T("commit_failed_pull_tip"))
}

if err := localcommit.Set(project.Dir(), commitID.String()); err != nil {
if err := commitmediator.Set(project, commitID.String()); err != nil {
return "", locale.WrapError(err, "err_package_update_commit_id")
}
return commitID, nil
Expand Down
19 changes: 10 additions & 9 deletions internal/runners/pull/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"github.com/ActiveState/cli/internal/prompt"
"github.com/ActiveState/cli/internal/runbits"
buildscriptRunbits "github.com/ActiveState/cli/internal/runbits/buildscript"
"github.com/ActiveState/cli/internal/runbits/commitmediator"
"github.com/ActiveState/cli/pkg/cmdlets/commit"
"github.com/ActiveState/cli/pkg/localcommit"
"github.com/ActiveState/cli/pkg/platform/api/mono/mono_models"
"github.com/ActiveState/cli/pkg/platform/authentication"
"github.com/ActiveState/cli/pkg/platform/model"
Expand Down Expand Up @@ -98,7 +98,7 @@ func (p *Pull) Run(params *PullParams) error {
}

var localCommit *strfmt.UUID
localCommitID, err := localcommit.Get(p.project.Dir())
localCommitID, err := commitmediator.Get(p.project)
if err != nil {
return errs.Wrap(err, "Unable to get local commit")
}
Expand Down Expand Up @@ -150,13 +150,13 @@ func (p *Pull) Run(params *PullParams) error {
}
}

commitID, err := localcommit.Get(p.project.Dir())
commitID, err := commitmediator.Get(p.project)
if err != nil {
return errs.Wrap(err, "Unable to get local commit")
}

if commitID != *resultingCommit {
err := localcommit.Set(p.project.Dir(), resultingCommit.String())
err := commitmediator.Set(p.project, resultingCommit.String())
if err != nil {
return errs.Wrap(err, "Unable to set local commit")
}
Expand All @@ -181,17 +181,18 @@ func (p *Pull) Run(params *PullParams) error {
}

func (p *Pull) performMerge(strategies *mono_models.MergeStrategies, remoteCommit strfmt.UUID, localCommit strfmt.UUID, namespace *project.Namespaced, branchName string) (strfmt.UUID, error) {
err := p.mergeBuildScript(strategies, remoteCommit)
if err != nil {
return "", errs.Wrap(err, "Could not merge local build script with remote changes")
}
// Re-enable in DX-2307.
//err := p.mergeBuildScript(strategies, remoteCommit)
//if err != nil {
// return "", errs.Wrap(err, "Could not merge local build script with remote changes")
//}

p.out.Notice(output.Title(locale.Tl("pull_diverged", "Merging history")))
p.out.Notice(locale.Tr(
"pull_diverged_message",
namespace.String(), branchName, localCommit.String(), remoteCommit.String()))

commitID, err := localcommit.Get(p.project.Dir())
commitID, err := commitmediator.Get(p.project)
if err != nil {
return "", errs.Wrap(err, "Unable to get local commit")
}
Expand Down
Loading