From fc95e97262a195ad83e2867aa030a719b23f65c7 Mon Sep 17 00:00:00 2001 From: mitchell Date: Mon, 30 Oct 2023 13:52:46 -0400 Subject: [PATCH 1/4] Temporarily disable localcommit files. --- internal/constraints/constraints.go | 3 +- .../runbits/commitmediator/commitmediator.go | 39 +++++++++------ internal/runbits/requirements/requirements.go | 9 ++-- internal/runners/branch/add.go | 5 +- internal/runners/initialize/init.go | 28 ++++++----- internal/runners/packages/import.go | 7 +-- internal/runners/pull/pull.go | 11 +++-- internal/runners/push/push.go | 11 +++-- internal/runners/reset/reset.go | 9 ++-- internal/runners/revert/revert.go | 7 +-- internal/runners/swtch/switch.go | 5 +- internal/testhelpers/e2e/session.go | 7 ++- pkg/cmdlets/checkout/checkout.go | 49 ++++++++++--------- pkg/project/project.go | 6 +++ pkg/project/project_test.go | 9 ++-- pkg/project/testdata/activestate.yaml | 2 +- pkg/projectfile/projectfield.go | 5 ++ pkg/projectfile/projectfile.go | 49 +++++++++++++++---- test/integration/checkout_int_test.go | 22 +++++---- test/integration/install_int_test.go | 10 ++-- .../integration/project_migration_int_test.go | 1 + test/integration/pull_int_test.go | 17 +++++-- test/integration/push_int_test.go | 14 ++++-- test/integration/switch_int_test.go | 15 +++--- 24 files changed, 215 insertions(+), 125 deletions(-) diff --git a/internal/constraints/constraints.go b/internal/constraints/constraints.go index fc454f90ee..6eb19cf192 100644 --- a/internal/constraints/constraints.go +++ b/internal/constraints/constraints.go @@ -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 { diff --git a/internal/runbits/commitmediator/commitmediator.go b/internal/runbits/commitmediator/commitmediator.go index 64bb3d2709..2998072013 100644 --- a/internal/runbits/commitmediator/commitmediator.go +++ b/internal/runbits/commitmediator/commitmediator.go @@ -1,9 +1,10 @@ package commitmediator import ( - "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/runbits/legacy/projectmigration" - "github.com/ActiveState/cli/pkg/localcommit" + // Re-enable in DX-2307. + //"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" ) @@ -12,22 +13,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) } diff --git a/internal/runbits/requirements/requirements.go b/internal/runbits/requirements/requirements.go index 03c8515564..8f90d429c4 100644 --- a/internal/runbits/requirements/requirements.go +++ b/internal/runbits/requirements/requirements.go @@ -19,8 +19,9 @@ 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" + //"github.com/ActiveState/cli/pkg/localcommit" // re-enable in DX-2307 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" @@ -108,7 +109,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") } @@ -190,7 +191,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") } @@ -274,7 +275,7 @@ func (r *RequirementOperation) ExecuteRequirementOperation(requirementName, requ 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") } diff --git a/internal/runners/branch/add.go b/internal/runners/branch/add.go index 800bb57140..8782994d67 100644 --- a/internal/runners/branch/add.go +++ b/internal/runners/branch/add.go @@ -5,7 +5,8 @@ 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/localcommit" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/project" ) @@ -49,7 +50,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") } diff --git a/internal/runners/initialize/init.go b/internal/runners/initialize/init.go index 7a61f94818..fd78ed49b3 100644 --- a/internal/runners/initialize/init.go +++ b/internal/runners/initialize/init.go @@ -20,7 +20,7 @@ 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/localcommit" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/platform/runtime/setup" @@ -157,10 +157,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. @@ -247,16 +248,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")) {B + // 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 { diff --git a/internal/runners/packages/import.go b/internal/runners/packages/import.go index 943d39f105..a4e30333ce 100644 --- a/internal/runners/packages/import.go +++ b/internal/runners/packages/import.go @@ -12,7 +12,8 @@ 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/localcommit" // re-enable in DX-2307 "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" @@ -177,7 +178,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") } @@ -188,7 +189,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 diff --git a/internal/runners/pull/pull.go b/internal/runners/pull/pull.go index 586f3569d9..4bd6903f19 100644 --- a/internal/runners/pull/pull.go +++ b/internal/runners/pull/pull.go @@ -15,8 +15,9 @@ 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/localcommit" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/api/mono/mono_models" "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" @@ -98,7 +99,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") } @@ -150,13 +151,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") } @@ -191,7 +192,7 @@ func (p *Pull) performMerge(strategies *mono_models.MergeStrategies, remoteCommi "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") } diff --git a/internal/runners/push/push.go b/internal/runners/push/push.go index 20367586ec..4bb4c71949 100644 --- a/internal/runners/push/push.go +++ b/internal/runners/push/push.go @@ -12,8 +12,9 @@ import ( "github.com/ActiveState/cli/internal/primer" "github.com/ActiveState/cli/internal/prompt" "github.com/ActiveState/cli/internal/rtutils/ptr" + "github.com/ActiveState/cli/internal/runbits/commitmediator" "github.com/ActiveState/cli/internal/runbits/rationalize" - "github.com/ActiveState/cli/pkg/localcommit" + //"github.com/ActiveState/cli/pkg/localcommit" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/api/mono/mono_models" "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" @@ -87,7 +88,7 @@ func (r *Push) Run(params PushParams) (rerr error) { } r.out.Notice(locale.Tl("operating_message", "", r.project.NamespaceString(), r.project.Dir())) - commitID, err := localcommit.Get(r.project.Dir()) // The commit we want to push + commitID, err := commitmediator.Get(r.project) // The commit we want to push if err != nil { // Note: should not get here, as verifyInput() ensures there is a local commit return errs.Wrap(err, "Unable to get local commit") @@ -191,7 +192,7 @@ func (r *Push) Run(params PushParams) (rerr error) { } // Update the project's commitID with the create project or push result. - if err := localcommit.Set(r.project.Dir(), commitID.String()); err != nil { + if err := commitmediator.Set(r.project, commitID.String()); err != nil { return errs.Wrap(err, "Unable to create local commit file") } @@ -297,7 +298,7 @@ func (r *Push) verifyInput() error { return rationalize.ErrNoProject } - 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") } @@ -335,7 +336,7 @@ func (r *Push) promptNamespace() (*project.Namespaced, error) { } var name string - commitID, err := localcommit.Get(r.project.Dir()) + commitID, err := commitmediator.Get(r.project) if err != nil { return nil, errs.Wrap(err, "Unable to get local commit") } diff --git a/internal/runners/reset/reset.go b/internal/runners/reset/reset.go index f64ac2cd6d..09777c94f3 100644 --- a/internal/runners/reset/reset.go +++ b/internal/runners/reset/reset.go @@ -8,7 +8,8 @@ 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/localcommit" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/platform/runtime/target" @@ -63,7 +64,7 @@ func (r *Reset) Run(params *Params) error { if err != nil { return locale.WrapError(err, "err_reset_latest_commit", "Could not get latest commit ID") } - localCommitID, err := localcommit.Get(r.project.Dir()) + localCommitID, err := commitmediator.Get(r.project) if err != nil { return errs.Wrap(err, "Unable to get local commit") } @@ -76,7 +77,7 @@ func (r *Reset) Run(params *Params) error { return locale.NewInputError("Invalid commit ID") } commitID = strfmt.UUID(params.CommitID) - localCommitID, err := localcommit.Get(r.project.Dir()) + localCommitID, err := commitmediator.Get(r.project) if err != nil { return errs.Wrap(err, "Unable to get local commit") } @@ -100,7 +101,7 @@ func (r *Reset) Run(params *Params) error { return locale.NewInputError("err_reset_aborted", "Reset aborted by user") } - err = localcommit.Set(r.project.Dir(), commitID.String()) + err = commitmediator.Set(r.project, commitID.String()) if err != nil { return errs.Wrap(err, "Unable to set local commit") } diff --git a/internal/runners/revert/revert.go b/internal/runners/revert/revert.go index f2e345a29a..46343352fa 100644 --- a/internal/runners/revert/revert.go +++ b/internal/runners/revert/revert.go @@ -8,8 +8,9 @@ import ( "github.com/ActiveState/cli/internal/primer" "github.com/ActiveState/cli/internal/prompt" "github.com/ActiveState/cli/internal/runbits" + "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/localcommit" // re-enable in DX-2307 gqlmodel "github.com/ActiveState/cli/pkg/platform/api/graphql/model" "github.com/ActiveState/cli/pkg/platform/api/mono/mono_models" "github.com/ActiveState/cli/pkg/platform/authentication" @@ -61,7 +62,7 @@ func (r *Revert) Run(params *Params) error { if !strfmt.IsUUID(params.CommitID) { return locale.NewInputError("err_invalid_commit_id", "Invalid commit ID") } - latestCommit, err := localcommit.Get(r.project.Dir()) + latestCommit, err := commitmediator.Get(r.project) if err != nil { return errs.Wrap(err, "Unable to get local commit") } @@ -139,7 +140,7 @@ func (r *Revert) Run(params *Params) error { return locale.WrapError(err, "err_refresh_runtime") } - err = localcommit.Set(r.project.Dir(), revertCommit.CommitID.String()) + err = commitmediator.Set(r.project, revertCommit.CommitID.String()) if err != nil { return errs.Wrap(err, "Unable to set local commit") } diff --git a/internal/runners/swtch/switch.go b/internal/runners/swtch/switch.go index 1f63120613..52f334c2ac 100644 --- a/internal/runners/swtch/switch.go +++ b/internal/runners/swtch/switch.go @@ -8,7 +8,8 @@ import ( "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/primer" "github.com/ActiveState/cli/internal/runbits" - "github.com/ActiveState/cli/pkg/localcommit" + "github.com/ActiveState/cli/internal/runbits/commitmediator" + //"github.com/ActiveState/cli/pkg/localcommit" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/api/mono/mono_models" "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" @@ -110,7 +111,7 @@ func (s *Switch) Run(params SwitchParams) error { return locale.NewInputError("err_identifier_branch_not_on_branch", "Commit does not belong to history for branch [ACTIONABLE]{{.V0}}[/RESET]", s.project.BranchName()) } - err = localcommit.Set(s.project.Dir(), identifier.CommitID().String()) + err = commitmediator.Set(s.project, identifier.CommitID().String()) if err != nil { return errs.Wrap(err, "Unable to set local commit") } diff --git a/internal/testhelpers/e2e/session.go b/internal/testhelpers/e2e/session.go index 2f25d5fd4f..93d22c0723 100644 --- a/internal/testhelpers/e2e/session.go +++ b/internal/testhelpers/e2e/session.go @@ -43,6 +43,7 @@ import ( "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/project" + "github.com/ActiveState/cli/pkg/projectfile" // remove in DX-2307 ) // Session represents an end-to-end testing session during which several console process can be spawned and tested @@ -380,7 +381,11 @@ func (s *Session) PrepareActiveStateYAML(contents string) { } func (s *Session) PrepareCommitIdFile(commitID string) { - require.NoError(s.t, fileutils.WriteFile(filepath.Join(s.Dirs.Work, constants.ProjectConfigDirName, constants.CommitIdFileName), []byte(commitID))) + // Replace the contents of this function with the line below in DX-2307. + //require.NoError(s.t, fileutils.WriteFile(filepath.Join(s.Dirs.Work, constants.ProjectConfigDirName, constants.CommitIdFileName), []byte(commitID))) + pjfile, err := projectfile.Parse(filepath.Join(s.Dirs.Work, constants.ConfigFileName)) + require.NoError(s.t, err) + require.NoError(s.t, pjfile.LegacySetCommit(commitID)) } // PrepareProject creates a very simple activestate.yaml file for the given org/project and, if a diff --git a/pkg/cmdlets/checkout/checkout.go b/pkg/cmdlets/checkout/checkout.go index 3a3e5235c9..af4ff463de 100644 --- a/pkg/cmdlets/checkout/checkout.go +++ b/pkg/cmdlets/checkout/checkout.go @@ -13,10 +13,10 @@ import ( "github.com/ActiveState/cli/internal/errs" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/language" - "github.com/ActiveState/cli/internal/multilog" + //"github.com/ActiveState/cli/internal/multilog" // re-enable in DX-2307 "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/pkg/cmdlets/git" - "github.com/ActiveState/cli/pkg/localcommit" + //"github.com/ActiveState/cli/pkg/localcommit" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/project" @@ -59,10 +59,11 @@ func (r *Checkout) Run(ns *project.Namespaced, branchName, cachePath, targetPath return "", errs.Wrap(err, "Could not get absolute path") } - 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) + //} // If project does not exist at path then we must checkout // the project and create the project file @@ -127,29 +128,31 @@ func (r *Checkout) Run(ns *project.Namespaced, branchName, cachePath, targetPath configFile := filepath.Join(path, constants.ConfigFileName) if !fileutils.FileExists(configFile) { _, err = projectfile.Create(&projectfile.CreateParams{ - Owner: owner, - Project: pj.Name, // match case on the Platform - BranchName: branchName, - Directory: path, - Language: language.String(), - Cache: cachePath, + Owner: owner, + Project: pj.Name, // match case on the Platform + BranchName: branchName, + Directory: path, + Language: language.String(), + Cache: cachePath, + LegacyCommitID: commitID.String(), // remove in DX-2307 }) if err != nil { return "", errs.Wrap(err, "Could not create projectfile") } } - err = localcommit.Set(path, commitID.String()) - if err != nil { - return "", errs.Wrap(err, "Could not create local commit file") - } - if emptyDir || fileutils.DirExists(filepath.Join(path, ".git")) { - err = localcommit.AddToGitIgnore(path) - if err != nil { - r.Outputer.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. + //err = localcommit.Set(path, commitID.String()) + //if err != nil { + // return "", errs.Wrap(err, "Could not create local commit file") + //} + //if emptyDir || fileutils.DirExists(filepath.Join(path, ".git")) { + // err = localcommit.AddToGitIgnore(path) + // if err != nil { + // r.Outputer.Notice(locale.Tr("notice_commit_id_gitignore", constants.ProjectConfigDirName, constants.CommitIdFileName)) + // multilog.Error("Unable to add local commit file to .gitignore: %v", err) + // } + //} return path, nil } diff --git a/pkg/project/project.go b/pkg/project/project.go index d1ffc0a559..448ffb6206 100644 --- a/pkg/project/project.go +++ b/pkg/project/project.go @@ -219,6 +219,12 @@ func (p *Project) LegacyCommitID() string { return p.projectfile.LegacyCommitID() } +// LegacySetCommit is for use by commitmediator.Set() ONLY. +// Remove in DX-2307. +func (p *Project) LegacySetCommit(commitID string) error { + return p.projectfile.LegacySetCommit(commitID) +} + func (p *Project) IsHeadless() bool { match := projectfile.CommitURLRe.FindStringSubmatch(p.URL()) return len(match) > 1 diff --git a/pkg/project/project_test.go b/pkg/project/project_test.go index b8c3ae4b63..ad57a276c3 100644 --- a/pkg/project/project_test.go +++ b/pkg/project/project_test.go @@ -11,8 +11,9 @@ import ( "github.com/ActiveState/cli/internal/environment" "github.com/ActiveState/cli/internal/errs" "github.com/ActiveState/cli/internal/language" + "github.com/ActiveState/cli/internal/runbits/commitmediator" "github.com/ActiveState/cli/internal/subshell" - "github.com/ActiveState/cli/pkg/localcommit" + //"github.com/ActiveState/cli/pkg/localcommit" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/project" "github.com/ActiveState/cli/pkg/projectfile" @@ -61,9 +62,11 @@ func (suite *ProjectTestSuite) TestGetSafe() { } func (suite *ProjectTestSuite) TestProject() { - suite.Equal("https://platform.activestate.com/ActiveState/project?branch=main", suite.project.URL(), "Values should match") + projectLine := "https://platform.activestate.com/ActiveState/project?branch=main" + projectLine += "&commitID=00010001-0001-0001-0001-000100010001" // remove in DX-2307 + suite.Equal(projectLine, suite.project.URL(), "Values should match") suite.Equal("project", suite.project.Name(), "Values should match") - commitID, err := localcommit.Get(suite.project.Dir()) + commitID, err := commitmediator.Get(suite.project) suite.NoError(err) suite.Equal("00010001-0001-0001-0001-000100010001", commitID.String(), "Values should match") suite.Equal("ActiveState", suite.project.Owner(), "Values should match") diff --git a/pkg/project/testdata/activestate.yaml b/pkg/project/testdata/activestate.yaml index 41f1f8d8ec..80908d57b2 100644 --- a/pkg/project/testdata/activestate.yaml +++ b/pkg/project/testdata/activestate.yaml @@ -1,4 +1,4 @@ -project: https://platform.activestate.com/ActiveState/project?branch=main +project: https://platform.activestate.com/ActiveState/project?branch=main&commitID=00010001-0001-0001-0001-000100010001 environments: "something" lock: "master@1.0.0-SHA123" namespace: "my/name/space" diff --git a/pkg/projectfile/projectfield.go b/pkg/projectfile/projectfield.go index f53555edb1..fbf3da6c5c 100644 --- a/pkg/projectfile/projectfield.go +++ b/pkg/projectfile/projectfield.go @@ -48,6 +48,11 @@ func (p *projectField) StripCommitID() { p.unsetQuery("commitID") // legacy } +// Remove this in DX-2307. +func (p *projectField) LegacySetCommit(commitID string) { + p.setQuery("commitID", commitID) +} + func (p *projectField) setPath(path string) { p.url.Path = path p.url.RawPath = p.url.EscapedPath() diff --git a/pkg/projectfile/projectfile.go b/pkg/projectfile/projectfile.go index ffab8e795d..664c7a72be 100644 --- a/pkg/projectfile/projectfile.go +++ b/pkg/projectfile/projectfile.go @@ -564,6 +564,29 @@ func (p *Project) LegacyCommitID() string { return p.parsedURL.LegacyCommitID } +// LegacySetCommit is for use by commitmediator.Set() ONLY. +// It changes the legacy commit ID in activestate.yaml. +// Remove this in DX-2307. +func (p *Project) LegacySetCommit(commitID string) error { + pf := NewProjectField() + if err := pf.LoadProject(p.Project); err != nil { + return errs.Wrap(err, "Could not load activestate.yaml") + } + pf.LegacySetCommit(commitID) + if err := pf.Save(p.path); err != nil { + return errs.Wrap(err, "Could not save activestate.yaml") + } + + p.parsedURL.LegacyCommitID = commitID + p.Project = pf.String() + return nil +} + +// Remove this function in DX-2307. +func (p *Project) Dir() string { + return filepath.Dir(p.path) +} + // SetPath sets the path of the project file and should generally only be used by tests func (p *Project) SetPath(path string) { p.path = path @@ -899,16 +922,17 @@ func FromExactPath(path string) (*Project, error) { // CreateParams are parameters that we create a custom activestate.yaml file from type CreateParams struct { - Owner string - Project string - BranchName string - Directory string - Content string - Language string - Private bool - path string - ProjectURL string - Cache string + Owner string + Project string + BranchName string + Directory string + Content string + Language string + Private bool + path string + ProjectURL string + Cache string + LegacyCommitID string // remove in DX-2307 } // Create will create a new activestate.yaml with a projectURL for the given details @@ -939,6 +963,11 @@ func createCustom(params *CreateParams, lang language.Language) (*Project, error q.Set("branch", params.BranchName) } + // Remove this block in DX-2307. + if params.LegacyCommitID != "" { + q.Set("commitID", params.LegacyCommitID) + } + u.RawQuery = q.Encode() params.ProjectURL = u.String() } diff --git a/test/integration/checkout_int_test.go b/test/integration/checkout_int_test.go index e016dc1d0f..ad12549a75 100644 --- a/test/integration/checkout_int_test.go +++ b/test/integration/checkout_int_test.go @@ -40,12 +40,13 @@ func (suite *CheckoutIntegrationTestSuite) TestCheckout() { suite.Require().True(fileutils.FileExists(filepath.Join(ts.Dirs.Work, constants.ConfigFileName)), "ActiveState-CLI/Python3 was not checked out properly") // Verify .activestate/commit and .gitignore were created. - projectConfigDir := filepath.Join(ts.Dirs.Work, constants.ProjectConfigDirName) - suite.Require().True(fileutils.DirExists(projectConfigDir), "state checkout should have created "+projectConfigDir) - suite.Assert().True(fileutils.FileExists(filepath.Join(projectConfigDir, constants.CommitIdFileName)), "commit file not created") - gitignoreFile := filepath.Join(ts.Dirs.Work, ".gitignore") - suite.Assert().True(fileutils.FileExists(gitignoreFile), "fresh checkout did not create .gitignore") - suite.Assert().Contains(string(fileutils.ReadFileUnsafe(gitignoreFile)), fmt.Sprintf("%s/%s", constants.ProjectConfigDirName, constants.CommitIdFileName), "commit file not added to .gitignore") + // Re-enable the following lines in DX-2307. + //projectConfigDir := filepath.Join(ts.Dirs.Work, constants.ProjectConfigDirName) + //suite.Require().True(fileutils.DirExists(projectConfigDir), "state checkout should have created "+projectConfigDir) + //suite.Assert().True(fileutils.FileExists(filepath.Join(projectConfigDir, constants.CommitIdFileName)), "commit file not created") + //gitignoreFile := filepath.Join(ts.Dirs.Work, ".gitignore") + //suite.Assert().True(fileutils.FileExists(gitignoreFile), "fresh checkout did not create .gitignore") + //suite.Assert().Contains(string(fileutils.ReadFileUnsafe(gitignoreFile)), fmt.Sprintf("%s/%s", constants.ProjectConfigDirName, constants.CommitIdFileName), "commit file not added to .gitignore") // Verify runtime was installed correctly and works. targetDir := target.ProjectDirToTargetDir(ts.Dirs.Work, ts.Dirs.Cache) @@ -152,10 +153,11 @@ func (suite *CheckoutIntegrationTestSuite) TestCheckoutWithFlags() { cp.Expect("Checked out") cp.ExpectExitCode(0) - suite.Require().True(fileutils.DirExists(python3Dir), "state checkout should have created "+python3Dir) - commitIdFile := filepath.Join(python3Dir, constants.ProjectConfigDirName, constants.CommitIdFileName) - suite.Require().True(fileutils.FileExists(commitIdFile), "ActiveState-CLI/Python3 was not checked out properly") - suite.Assert().Equal(string(fileutils.ReadFileUnsafe(commitIdFile)), "6d9280e7-75eb-401a-9e71-0d99759fbad3", "did not check out specific commit ID") + // Re-enable the following lines in DX-2307. + //suite.Require().True(fileutils.DirExists(python3Dir), "state checkout should have created "+python3Dir) + //commitIdFile := filepath.Join(python3Dir, constants.ProjectConfigDirName, constants.CommitIdFileName) + //suite.Require().True(fileutils.FileExists(commitIdFile), "ActiveState-CLI/Python3 was not checked out properly") + //suite.Assert().Equal(string(fileutils.ReadFileUnsafe(commitIdFile)), "6d9280e7-75eb-401a-9e71-0d99759fbad3", "did not check out specific commit ID") // Test --branch mismatch in non-checked-out project. branchPath := filepath.Join(ts.Dirs.Base, "branch") diff --git a/test/integration/install_int_test.go b/test/integration/install_int_test.go index 0851c5bfd4..7f78ff5846 100644 --- a/test/integration/install_int_test.go +++ b/test/integration/install_int_test.go @@ -32,12 +32,14 @@ func (suite *InstallIntegrationTestSuite) TestInstall_InvalidCommit() { ts.PrepareProject("ActiveState-CLI/small-python", "malformed-commit-id") cp := ts.SpawnWithOpts(e2e.OptArgs("install", "trender")) - cp.Expect("Could not find or read the commit file") + //cp.Expect("Could not find or read the commit file") // re-enable in DX-2307 + cp.Expect("Invalid commit ID") // remove in DX-2307 cp.ExpectExitCode(1) - if strings.Count(cp.Snapshot(), " x ") != 1 { - suite.Fail("Expected exactly ONE error message, got: ", cp.Snapshot()) - } + // Re-enable in DX-2307. + //if strings.Count(cp.Snapshot(), " x ") != 1 { + // suite.Fail("Expected exactly ONE error message, got: ", cp.Snapshot()) + //} } func (suite *InstallIntegrationTestSuite) TestInstall_NoMatches_NoAlternatives() { diff --git a/test/integration/project_migration_int_test.go b/test/integration/project_migration_int_test.go index a39c648f7a..494b081a42 100644 --- a/test/integration/project_migration_int_test.go +++ b/test/integration/project_migration_int_test.go @@ -18,6 +18,7 @@ type ProjectMigrationIntegrationTestSuite struct { func (suite *ProjectMigrationIntegrationTestSuite) TestPromptMigration() { suite.OnlyRunForTags(tagsuite.Critical) + suite.T().Skip("Temporarily disabling project migration until DX-2307") // remove in DX-2307 ts := e2e.New(suite.T(), false) defer ts.Close() diff --git a/test/integration/pull_int_test.go b/test/integration/pull_int_test.go index d16923cbee..0f024b620a 100644 --- a/test/integration/pull_int_test.go +++ b/test/integration/pull_int_test.go @@ -12,6 +12,7 @@ import ( "github.com/ActiveState/cli/internal/testhelpers/tagsuite" "github.com/ActiveState/cli/pkg/platform/runtime/buildscript" "github.com/ActiveState/cli/pkg/project" + "github.com/ActiveState/cli/pkg/projectfile" // remove in DX-2307 "github.com/stretchr/testify/suite" ) @@ -32,9 +33,10 @@ func (suite *PullIntegrationTestSuite) TestPull() { cp.Expect("activestate.yaml has been updated") cp.ExpectExitCode(0) - projectConfigDir := filepath.Join(ts.Dirs.Work, constants.ProjectConfigDirName) - suite.Require().True(fileutils.DirExists(projectConfigDir)) - suite.Assert().True(fileutils.FileExists(filepath.Join(projectConfigDir, constants.CommitIdFileName))) + // Re-enable this block in DX-2307. + //projectConfigDir := filepath.Join(ts.Dirs.Work, constants.ProjectConfigDirName) + //suite.Require().True(fileutils.DirExists(projectConfigDir)) + //suite.Assert().True(fileutils.FileExists(filepath.Join(projectConfigDir, constants.CommitIdFileName))) cp = ts.Spawn("pull") cp.Expect("already up to date") @@ -90,9 +92,14 @@ func (suite *PullIntegrationTestSuite) TestPull_Merge() { pjfilepath := filepath.Join(ts.Dirs.Work, "cli", constants.ConfigFileName) err := fileutils.WriteFile(pjfilepath, []byte(projectLine)) suite.Require().NoError(err) - commitIdFile := filepath.Join(ts.Dirs.Work, "cli", constants.ProjectConfigDirName, constants.CommitIdFileName) - err = fileutils.WriteFile(commitIdFile, []byte(unPulledCommit)) + // Remove the following lines in DX-2307. + pjfile, err := projectfile.Parse(pjfilepath) suite.Require().NoError(err) + suite.Require().NoError(pjfile.LegacySetCommit(unPulledCommit)) + // Re-enable the following lines in DX-2307. + //commitIdFile := filepath.Join(ts.Dirs.Work, "cli", constants.ProjectConfigDirName, constants.CommitIdFileName) + //err = fileutils.WriteFile(commitIdFile, []byte(unPulledCommit)) + //suite.Require().NoError(err) ts.LoginAsPersistentUser() diff --git a/test/integration/push_int_test.go b/test/integration/push_int_test.go index f12b75524f..90ec0ce493 100644 --- a/test/integration/push_int_test.go +++ b/test/integration/push_int_test.go @@ -13,10 +13,11 @@ import ( "github.com/ActiveState/cli/internal/constants" "github.com/ActiveState/cli/internal/fileutils" + "github.com/ActiveState/cli/internal/runbits/commitmediator" "github.com/ActiveState/cli/internal/strutils" "github.com/ActiveState/cli/internal/testhelpers/e2e" "github.com/ActiveState/cli/internal/testhelpers/tagsuite" - "github.com/ActiveState/cli/pkg/localcommit" + //"github.com/ActiveState/cli/pkg/localcommit" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/project" "github.com/ActiveState/cli/pkg/projectfile" ) @@ -73,7 +74,7 @@ func (suite *PushIntegrationTestSuite) TestInitAndPush() { // Check that languages were reset pjfile, err := projectfile.Parse(pjfilepath) suite.Require().NoError(err) - commitID, err := localcommit.Get(filepath.Join(ts.Dirs.Work, namespace)) + commitID, err := commitmediator.Get(pjfile) suite.Require().NoError(err) suite.Require().NotEmpty(commitID.String(), "commitID was not set after running push for project creation") suite.Require().NotEmpty(pjfile.BranchName(), "branch was not set after running push for project creation") @@ -359,8 +360,13 @@ func (suite *PushIntegrationTestSuite) TestPush_Outdated() { wd := filepath.Join(ts.Dirs.Work, "cli") pjfilepath := filepath.Join(ts.Dirs.Work, "cli", constants.ConfigFileName) suite.Require().NoError(fileutils.WriteFile(pjfilepath, []byte(projectLine))) - commitIdFile := filepath.Join(ts.Dirs.Work, "cli", constants.ProjectConfigDirName, constants.CommitIdFileName) - suite.Require().NoError(fileutils.WriteFile(commitIdFile, []byte(unPushedCommit))) + // Remove the following lines in DX-2307. + pjfile, err := projectfile.Parse(pjfilepath) + suite.Require().NoError(err) + suite.Require().NoError(pjfile.LegacySetCommit(unPushedCommit)) + // Re-enable the following lines in DX-2307. + //commitIdFile := filepath.Join(ts.Dirs.Work, "cli", constants.ProjectConfigDirName, constants.CommitIdFileName) + //suite.Require().NoError(fileutils.WriteFile(commitIdFile, []byte(unPushedCommit))) ts.LoginAsPersistentUser() cp := ts.SpawnWithOpts(e2e.OptArgs("push"), e2e.OptWD(wd)) diff --git a/test/integration/switch_int_test.go b/test/integration/switch_int_test.go index 7508c78de8..f87255c21b 100644 --- a/test/integration/switch_int_test.go +++ b/test/integration/switch_int_test.go @@ -6,9 +6,10 @@ import ( "testing" "github.com/ActiveState/cli/internal/constants" + "github.com/ActiveState/cli/internal/runbits/commitmediator" "github.com/ActiveState/cli/internal/testhelpers/e2e" "github.com/ActiveState/cli/internal/testhelpers/tagsuite" - "github.com/ActiveState/cli/pkg/localcommit" + //"github.com/ActiveState/cli/pkg/localcommit" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/projectfile" "github.com/stretchr/testify/suite" ) @@ -31,7 +32,7 @@ func (suite *SwitchIntegrationTestSuite) TestSwitch_Branch() { pjfile, err := projectfile.Parse(pjfilepath) suite.Require().NoError(err) suite.Require().Equal("main", pjfile.BranchName(), "branch was not set to 'main' after pull") - mainBranchCommitID, err := localcommit.Get(ts.Dirs.Work) + mainBranchCommitID, err := commitmediator.Get(pjfile) suite.Require().NoError(err) cp := ts.SpawnWithOpts(e2e.OptArgs("switch", "secondbranch")) @@ -45,7 +46,7 @@ func (suite *SwitchIntegrationTestSuite) TestSwitch_Branch() { // Check that branch and commitID were updated pjfile, err = projectfile.Parse(pjfilepath) suite.Require().NoError(err) - commitID, err := localcommit.Get(ts.Dirs.Work) + commitID, err := commitmediator.Get(pjfile) suite.Require().NoError(err) suite.Require().NotEqual(mainBranchCommitID, commitID, "commitID was not updated after switching branches") suite.Require().Equal("secondbranch", pjfile.BranchName(), "branch was not updated after switching branches") @@ -65,7 +66,7 @@ func (suite *SwitchIntegrationTestSuite) TestSwitch_CommitID() { pjfile, err := projectfile.Parse(pjfilepath) suite.Require().NoError(err) suite.Require().Equal("main", pjfile.BranchName(), "branch was not set to 'main' after pull") - originalCommitID, err := localcommit.Get(ts.Dirs.Work) + originalCommitID, err := commitmediator.Get(pjfile) suite.Require().NoError(err) cp := ts.SpawnWithOpts(e2e.OptArgs("switch", "efce7c7a-c61a-4b04-bb00-f8e7edfd247f")) @@ -77,7 +78,7 @@ func (suite *SwitchIntegrationTestSuite) TestSwitch_CommitID() { // Check that branch and commitID were updated pjfile, err = projectfile.Parse(pjfilepath) suite.Require().NoError(err) - commitID, err := localcommit.Get(ts.Dirs.Work) + commitID, err := commitmediator.Get(pjfile) suite.Require().NotEqual(originalCommitID, commitID, "commitID was not updated after switching branches") } @@ -95,7 +96,7 @@ func (suite *SwitchIntegrationTestSuite) TestSwitch_CommitID_NotInHistory() { pjfile, err := projectfile.Parse(pjfilepath) suite.Require().NoError(err) suite.Require().Equal("main", pjfile.BranchName(), "branch was not set to 'main' after pull") - originalCommitID, err := localcommit.Get(ts.Dirs.Work) + originalCommitID, err := commitmediator.Get(pjfile) suite.Require().NoError(err) cp := ts.SpawnWithOpts(e2e.OptArgs("switch", "76dff77a-66b9-43e3-90be-dc75917dd661")) @@ -107,7 +108,7 @@ func (suite *SwitchIntegrationTestSuite) TestSwitch_CommitID_NotInHistory() { // Check that branch and commitID were not updated pjfile, err = projectfile.Parse(pjfilepath) suite.Require().NoError(err) - commitID, err := localcommit.Get(ts.Dirs.Work) + commitID, err := commitmediator.Get(pjfile) suite.Require().NoError(err) suite.Equal(originalCommitID, commitID, "commitID was updated after switching branches") } From c2215ab66ec5f96f426c5f4e87e6c574c5f51396 Mon Sep 17 00:00:00 2001 From: mitchell Date: Mon, 30 Oct 2023 14:01:32 -0400 Subject: [PATCH 2/4] Temporarily disable buildscripts. --- cmd/state/internal/cmdtree/cmdtree.go | 2 +- internal/runbits/refresh.go | 11 +++++----- internal/runbits/requirements/requirements.go | 20 ++++++++++--------- internal/runners/pull/pull.go | 9 +++++---- pkg/platform/runtime/runtime.go | 2 ++ pkg/platform/runtime/setup/setup.go | 9 +++++---- test/integration/commit_int_test.go | 1 + test/integration/pull_int_test.go | 1 + 8 files changed, 32 insertions(+), 23 deletions(-) diff --git a/cmd/state/internal/cmdtree/cmdtree.go b/cmd/state/internal/cmdtree/cmdtree.go index 2a26337532..2abab6d5df 100644 --- a/cmd/state/internal/cmdtree/cmdtree.go +++ b/cmd/state/internal/cmdtree/cmdtree.go @@ -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{ diff --git a/internal/runbits/refresh.go b/internal/runbits/refresh.go index b7d569b4a4..6bc5d6386a 100644 --- a/internal/runbits/refresh.go +++ b/internal/runbits/refresh.go @@ -5,7 +5,7 @@ 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/internal/runbits/buildscript" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/platform/runtime" @@ -25,10 +25,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) diff --git a/internal/runbits/requirements/requirements.go b/internal/runbits/requirements/requirements.go index 8f90d429c4..9576eab0e0 100644 --- a/internal/runbits/requirements/requirements.go +++ b/internal/runbits/requirements/requirements.go @@ -26,7 +26,7 @@ import ( 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/buildscript" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/runtime/target" "github.com/ActiveState/cli/pkg/project" "github.com/thoas/go-funk" @@ -270,20 +270,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 := 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) diff --git a/internal/runners/pull/pull.go b/internal/runners/pull/pull.go index 4bd6903f19..4c0284a679 100644 --- a/internal/runners/pull/pull.go +++ b/internal/runners/pull/pull.go @@ -182,10 +182,11 @@ 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( diff --git a/pkg/platform/runtime/runtime.go b/pkg/platform/runtime/runtime.go index 806ea0e22e..e3441f5b72 100644 --- a/pkg/platform/runtime/runtime.go +++ b/pkg/platform/runtime/runtime.go @@ -116,6 +116,8 @@ func (r *Runtime) validateCache() error { return nil } + return nil // remove in DX-2307 to re-enable buildscripts below + // Check if local build script has changes that should be committed. script, err := buildscript.NewScriptFromProject(r.target, r.auth) if err != nil { diff --git a/pkg/platform/runtime/setup/setup.go b/pkg/platform/runtime/setup/setup.go index 252aa45cbd..e03062567f 100644 --- a/pkg/platform/runtime/setup/setup.go +++ b/pkg/platform/runtime/setup/setup.go @@ -36,7 +36,7 @@ import ( "github.com/ActiveState/cli/pkg/platform/runtime/artifact" "github.com/ActiveState/cli/pkg/platform/runtime/artifactcache" "github.com/ActiveState/cli/pkg/platform/runtime/buildplan" - "github.com/ActiveState/cli/pkg/platform/runtime/buildscript" + //"github.com/ActiveState/cli/pkg/platform/runtime/buildscript" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/runtime/envdef" "github.com/ActiveState/cli/pkg/platform/runtime/executors" "github.com/ActiveState/cli/pkg/platform/runtime/setup/buildlog" @@ -582,9 +582,10 @@ func (s *Setup) fetchAndInstallArtifactsFromBuildPlan(installFunc artifactInstal } if s.target.ProjectDir() != "" { - if err := buildscript.Update(s.target, buildResult.BuildExpression, s.auth); err != nil { - return nil, nil, errs.Wrap(err, "Could not save build script.") - } + // Re-enable in DX-2307 + //if err := buildscript.Update(s.target, buildResult.BuildExpression, s.auth); err != nil { + // return nil, nil, errs.Wrap(err, "Could not save build script.") + //} } return buildResult.OrderedArtifacts(), uninstallArtifacts, nil diff --git a/test/integration/commit_int_test.go b/test/integration/commit_int_test.go index 4f4693eee0..d88a27b373 100644 --- a/test/integration/commit_int_test.go +++ b/test/integration/commit_int_test.go @@ -20,6 +20,7 @@ type CommitIntegrationTestSuite struct { func (suite *CommitIntegrationTestSuite) TestCommitManualBuildScriptMod() { suite.OnlyRunForTags(tagsuite.Commit) + suite.T().Skip("Temporarily disable buildscripts until DX-2307") // remove in DX-2307 ts := e2e.New(suite.T(), false) defer ts.Close() diff --git a/test/integration/pull_int_test.go b/test/integration/pull_int_test.go index 0f024b620a..cdc2851a10 100644 --- a/test/integration/pull_int_test.go +++ b/test/integration/pull_int_test.go @@ -141,6 +141,7 @@ func (suite *PullIntegrationTestSuite) TestPull_RestoreNamespace() { func (suite *PullIntegrationTestSuite) TestMergeBuildScript() { suite.OnlyRunForTags(tagsuite.Pull) + suite.T().Skip("Temporarily disable buildscripts until DX-2307") // remove in DX-2307 ts := e2e.New(suite.T(), false) defer ts.Close() From a3186331b653c83c42f088a468369d5ad5ae4197 Mon Sep 17 00:00:00 2001 From: mitchell Date: Tue, 31 Oct 2023 18:15:00 -0400 Subject: [PATCH 3/4] Address PR feedback. --- internal/runbits/commitmediator/commitmediator.go | 4 ---- internal/runners/initialize/init.go | 2 +- test/integration/checkout_int_test.go | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/internal/runbits/commitmediator/commitmediator.go b/internal/runbits/commitmediator/commitmediator.go index 2998072013..37e5df525c 100644 --- a/internal/runbits/commitmediator/commitmediator.go +++ b/internal/runbits/commitmediator/commitmediator.go @@ -1,10 +1,6 @@ package commitmediator import ( - // Re-enable in DX-2307. - //"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" ) diff --git a/internal/runners/initialize/init.go b/internal/runners/initialize/init.go index fd78ed49b3..af33f7aa27 100644 --- a/internal/runners/initialize/init.go +++ b/internal/runners/initialize/init.go @@ -252,7 +252,7 @@ func (r *Initialize) Run(params *RunParams) (rerr error) { return errs.Wrap(err, "Unable to create local commit file") } // Re-enable in DX-2307. - //if emptyDir || fileutils.DirExists(filepath.Join(path, ".git")) {B + //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)) diff --git a/test/integration/checkout_int_test.go b/test/integration/checkout_int_test.go index ad12549a75..e1984baeb5 100644 --- a/test/integration/checkout_int_test.go +++ b/test/integration/checkout_int_test.go @@ -153,8 +153,8 @@ func (suite *CheckoutIntegrationTestSuite) TestCheckoutWithFlags() { cp.Expect("Checked out") cp.ExpectExitCode(0) + suite.Require().True(fileutils.DirExists(python3Dir), "state checkout should have created "+python3Dir) // Re-enable the following lines in DX-2307. - //suite.Require().True(fileutils.DirExists(python3Dir), "state checkout should have created "+python3Dir) //commitIdFile := filepath.Join(python3Dir, constants.ProjectConfigDirName, constants.CommitIdFileName) //suite.Require().True(fileutils.FileExists(commitIdFile), "ActiveState-CLI/Python3 was not checked out properly") //suite.Assert().Equal(string(fileutils.ReadFileUnsafe(commitIdFile)), "6d9280e7-75eb-401a-9e71-0d99759fbad3", "did not check out specific commit ID") From eae791b1feb6c6b02fa1dd021a08d9aab73bf82e Mon Sep 17 00:00:00 2001 From: mitchell Date: Tue, 31 Oct 2023 18:18:14 -0400 Subject: [PATCH 4/4] Remove comments in imports. --- internal/runbits/refresh.go | 1 - internal/runbits/requirements/requirements.go | 2 -- internal/runners/branch/add.go | 1 - internal/runners/initialize/init.go | 1 - internal/runners/packages/import.go | 1 - internal/runners/pull/pull.go | 1 - internal/runners/push/push.go | 1 - internal/runners/reset/reset.go | 1 - internal/runners/revert/revert.go | 1 - internal/runners/swtch/switch.go | 1 - pkg/cmdlets/checkout/checkout.go | 2 -- pkg/platform/runtime/setup/setup.go | 1 - pkg/project/project_test.go | 1 - test/integration/push_int_test.go | 1 - test/integration/switch_int_test.go | 1 - 15 files changed, 17 deletions(-) diff --git a/internal/runbits/refresh.go b/internal/runbits/refresh.go index 6bc5d6386a..0dd7d9341c 100644 --- a/internal/runbits/refresh.go +++ b/internal/runbits/refresh.go @@ -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" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/platform/runtime" diff --git a/internal/runbits/requirements/requirements.go b/internal/runbits/requirements/requirements.go index 9576eab0e0..5faf07f963 100644 --- a/internal/runbits/requirements/requirements.go +++ b/internal/runbits/requirements/requirements.go @@ -21,12 +21,10 @@ import ( "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" // re-enable in DX-2307 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" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/runtime/target" "github.com/ActiveState/cli/pkg/project" "github.com/thoas/go-funk" diff --git a/internal/runners/branch/add.go b/internal/runners/branch/add.go index 8782994d67..e3730936d0 100644 --- a/internal/runners/branch/add.go +++ b/internal/runners/branch/add.go @@ -6,7 +6,6 @@ import ( "github.com/ActiveState/cli/internal/logging" "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/runbits/commitmediator" - //"github.com/ActiveState/cli/pkg/localcommit" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/project" ) diff --git a/internal/runners/initialize/init.go b/internal/runners/initialize/init.go index af33f7aa27..9703958965 100644 --- a/internal/runners/initialize/init.go +++ b/internal/runners/initialize/init.go @@ -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" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/platform/runtime/setup" diff --git a/internal/runners/packages/import.go b/internal/runners/packages/import.go index a4e30333ce..c49036a7b3 100644 --- a/internal/runners/packages/import.go +++ b/internal/runners/packages/import.go @@ -13,7 +13,6 @@ import ( "github.com/ActiveState/cli/internal/prompt" "github.com/ActiveState/cli/internal/runbits" "github.com/ActiveState/cli/internal/runbits/commitmediator" - //"github.com/ActiveState/cli/pkg/localcommit" // re-enable in DX-2307 "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" diff --git a/internal/runners/pull/pull.go b/internal/runners/pull/pull.go index 4c0284a679..cec6397029 100644 --- a/internal/runners/pull/pull.go +++ b/internal/runners/pull/pull.go @@ -17,7 +17,6 @@ import ( 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" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/api/mono/mono_models" "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" diff --git a/internal/runners/push/push.go b/internal/runners/push/push.go index 4bb4c71949..9908fc4d98 100644 --- a/internal/runners/push/push.go +++ b/internal/runners/push/push.go @@ -14,7 +14,6 @@ import ( "github.com/ActiveState/cli/internal/rtutils/ptr" "github.com/ActiveState/cli/internal/runbits/commitmediator" "github.com/ActiveState/cli/internal/runbits/rationalize" - //"github.com/ActiveState/cli/pkg/localcommit" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/api/mono/mono_models" "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" diff --git a/internal/runners/reset/reset.go b/internal/runners/reset/reset.go index 09777c94f3..53427a68d4 100644 --- a/internal/runners/reset/reset.go +++ b/internal/runners/reset/reset.go @@ -9,7 +9,6 @@ import ( "github.com/ActiveState/cli/internal/prompt" "github.com/ActiveState/cli/internal/runbits" "github.com/ActiveState/cli/internal/runbits/commitmediator" - //"github.com/ActiveState/cli/pkg/localcommit" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/platform/runtime/target" diff --git a/internal/runners/revert/revert.go b/internal/runners/revert/revert.go index 46343352fa..0462e26bbc 100644 --- a/internal/runners/revert/revert.go +++ b/internal/runners/revert/revert.go @@ -10,7 +10,6 @@ import ( "github.com/ActiveState/cli/internal/runbits" "github.com/ActiveState/cli/internal/runbits/commitmediator" "github.com/ActiveState/cli/pkg/cmdlets/commit" - //"github.com/ActiveState/cli/pkg/localcommit" // re-enable in DX-2307 gqlmodel "github.com/ActiveState/cli/pkg/platform/api/graphql/model" "github.com/ActiveState/cli/pkg/platform/api/mono/mono_models" "github.com/ActiveState/cli/pkg/platform/authentication" diff --git a/internal/runners/swtch/switch.go b/internal/runners/swtch/switch.go index 52f334c2ac..b194786fc0 100644 --- a/internal/runners/swtch/switch.go +++ b/internal/runners/swtch/switch.go @@ -9,7 +9,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" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/api/mono/mono_models" "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" diff --git a/pkg/cmdlets/checkout/checkout.go b/pkg/cmdlets/checkout/checkout.go index af4ff463de..26bd63b2ab 100644 --- a/pkg/cmdlets/checkout/checkout.go +++ b/pkg/cmdlets/checkout/checkout.go @@ -13,10 +13,8 @@ import ( "github.com/ActiveState/cli/internal/errs" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/language" - //"github.com/ActiveState/cli/internal/multilog" // re-enable in DX-2307 "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/pkg/cmdlets/git" - //"github.com/ActiveState/cli/pkg/localcommit" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/project" diff --git a/pkg/platform/runtime/setup/setup.go b/pkg/platform/runtime/setup/setup.go index e03062567f..5a473c2a3d 100644 --- a/pkg/platform/runtime/setup/setup.go +++ b/pkg/platform/runtime/setup/setup.go @@ -36,7 +36,6 @@ import ( "github.com/ActiveState/cli/pkg/platform/runtime/artifact" "github.com/ActiveState/cli/pkg/platform/runtime/artifactcache" "github.com/ActiveState/cli/pkg/platform/runtime/buildplan" - //"github.com/ActiveState/cli/pkg/platform/runtime/buildscript" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/runtime/envdef" "github.com/ActiveState/cli/pkg/platform/runtime/executors" "github.com/ActiveState/cli/pkg/platform/runtime/setup/buildlog" diff --git a/pkg/project/project_test.go b/pkg/project/project_test.go index ad57a276c3..57bd0a392d 100644 --- a/pkg/project/project_test.go +++ b/pkg/project/project_test.go @@ -13,7 +13,6 @@ import ( "github.com/ActiveState/cli/internal/language" "github.com/ActiveState/cli/internal/runbits/commitmediator" "github.com/ActiveState/cli/internal/subshell" - //"github.com/ActiveState/cli/pkg/localcommit" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/project" "github.com/ActiveState/cli/pkg/projectfile" diff --git a/test/integration/push_int_test.go b/test/integration/push_int_test.go index 90ec0ce493..4615c9f9b7 100644 --- a/test/integration/push_int_test.go +++ b/test/integration/push_int_test.go @@ -17,7 +17,6 @@ import ( "github.com/ActiveState/cli/internal/strutils" "github.com/ActiveState/cli/internal/testhelpers/e2e" "github.com/ActiveState/cli/internal/testhelpers/tagsuite" - //"github.com/ActiveState/cli/pkg/localcommit" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/project" "github.com/ActiveState/cli/pkg/projectfile" ) diff --git a/test/integration/switch_int_test.go b/test/integration/switch_int_test.go index f87255c21b..c755cf5897 100644 --- a/test/integration/switch_int_test.go +++ b/test/integration/switch_int_test.go @@ -9,7 +9,6 @@ import ( "github.com/ActiveState/cli/internal/runbits/commitmediator" "github.com/ActiveState/cli/internal/testhelpers/e2e" "github.com/ActiveState/cli/internal/testhelpers/tagsuite" - //"github.com/ActiveState/cli/pkg/localcommit" // re-enable in DX-2307 "github.com/ActiveState/cli/pkg/projectfile" "github.com/stretchr/testify/suite" )