diff --git a/cmd/state/internal/cmdtree/cmdtree.go b/cmd/state/internal/cmdtree/cmdtree.go index a72f479841..8322a15ba2 100644 --- a/cmd/state/internal/cmdtree/cmdtree.go +++ b/cmd/state/internal/cmdtree/cmdtree.go @@ -208,7 +208,7 @@ func New(prime *primer.Values, args ...string) *CmdTree { refreshCmd, newSwitchCommand(prime), newTestCommand(prime), - //newCommitCommand(prime), // re-enable in DX-2307 + newCommitCommand(prime), newPublish(prime), ) diff --git a/internal/constraints/constraints.go b/internal/constraints/constraints.go index 6eb19cf192..76b099557f 100644 --- a/internal/constraints/constraints.go +++ b/internal/constraints/constraints.go @@ -82,7 +82,6 @@ type projectable interface { Dir() string URL() string 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/checkout/checkout.go b/internal/runbits/checkout/checkout.go index 547b06dd7e..34124c7ef4 100644 --- a/internal/runbits/checkout/checkout.go +++ b/internal/runbits/checkout/checkout.go @@ -13,9 +13,11 @@ 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/osutils" "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/runbits/git" + "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/project" @@ -58,11 +60,13 @@ func (r *Checkout) Run(ns *project.Namespaced, branchName, cachePath, targetPath return "", errs.Wrap(err, "Could not get absolute path") } - // Re-enable in DX-2307. - //emptyDir, err := fileutils.IsEmptyDir(path) - //if err != nil { - // multilog.Error("Unable to check if directory is empty: %v", err) - //} + emptyDir := true + if fileutils.DirExists(path) { + 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 @@ -140,13 +144,12 @@ 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, - LegacyCommitID: commitID.String(), // remove in DX-2307 + Owner: owner, + Project: pj.Name, // match case on the Platform + BranchName: branchName, + Directory: path, + Language: language.String(), + Cache: cachePath, }) if err != nil { if osutils.IsAccessDeniedError(err) { @@ -156,18 +159,17 @@ func (r *Checkout) Run(ns *project.Namespaced, branchName, cachePath, targetPath } } - // 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) - // } - //} + 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/internal/runbits/commitmediator/commitmediator.go b/internal/runbits/commitmediator/commitmediator.go index 37e5df525c..d4d8bd73da 100644 --- a/internal/runbits/commitmediator/commitmediator.go +++ b/internal/runbits/commitmediator/commitmediator.go @@ -2,6 +2,10 @@ package commitmediator import ( "github.com/go-openapi/strfmt" + + "github.com/ActiveState/cli/internal/errs" + "github.com/ActiveState/cli/internal/runbits/legacy/projectmigration" + "github.com/ActiveState/cli/pkg/localcommit" ) type projecter interface { @@ -9,30 +13,26 @@ 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) { - // 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") - //} + 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) + return localcommit.Set(proj.Dir(), commitID) } diff --git a/internal/runbits/refresh.go b/internal/runbits/refresh.go index b4f0bababb..42f41c105f 100644 --- a/internal/runbits/refresh.go +++ b/internal/runbits/refresh.go @@ -5,6 +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/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/platform/runtime" @@ -25,11 +26,10 @@ func RefreshRuntime( svcm *model.SvcModel, cfg model.Configurable, ) (rerr error) { - // Re-enable in DX-2307. - //_, err := buildscript.Sync(proj, &commitID, out, auth) - //if err != nil { - // return locale.WrapError(err, "err_update_build_script") - //} + _, err := buildscript.Sync(proj, &commitID, out, auth) + if err != nil { + return locale.WrapError(err, "err_update_build_script") + } target := target.NewProjectTarget(proj, resolveCommitID(proj, &commitID), trigger) isCached := true rt, err := runtime.New(target, an, svcm, auth, cfg) diff --git a/internal/runbits/requirements/requirements.go b/internal/runbits/requirements/requirements.go index d8bb332b00..7633a33974 100644 --- a/internal/runbits/requirements/requirements.go +++ b/internal/runbits/requirements/requirements.go @@ -28,6 +28,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/target" "github.com/ActiveState/cli/pkg/project" "github.com/go-openapi/strfmt" @@ -281,19 +282,13 @@ func (r *RequirementOperation) ExecuteRequirementOperation( return errs.Wrap(err, "Unsupported namespace type: %s", ns.Type().String()) } - // 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") - //} - // refresh or install runtime err = runbits.RefreshRuntime(r.Auth, r.Output, r.Analytics, r.Project, commitID, true, trigger, r.SvcModel, r.Config) if err != nil { - return handleRefreshError(err, r.Project, parentCommitID) + return r.handleRefreshError(err, parentCommitID) } - if err := updateCommitID(r.Project, commitID); err != nil { + if err := r.updateCommitID(commitID); err != nil { return locale.WrapError(err, "err_package_update_commit_id") } @@ -331,28 +326,32 @@ func (r *RequirementOperation) ExecuteRequirementOperation( return nil } -func handleRefreshError(err error, project *project.Project, parentCommitID strfmt.UUID) error { +func (r *RequirementOperation) handleRefreshError(err error, parentCommitID strfmt.UUID) error { // If the error is a build error then return, if not update the commit ID then return if !runbits.IsBuildError(err) { - if err := updateCommitID(project, parentCommitID); err != nil { + if err := r.updateCommitID(parentCommitID); err != nil { return locale.WrapError(err, "err_package_update_commit_id") } } return err } -func updateCommitID(project *project.Project, commitID strfmt.UUID) error { - if err := commitmediator.Set(project, commitID.String()); err != nil { +func (r *RequirementOperation) updateCommitID(commitID strfmt.UUID) error { + if err := commitmediator.Set(r.Project, commitID.String()); err != nil { return locale.WrapError(err, "err_package_update_commit_id") } + bp := model.NewBuildPlannerModel(r.Auth) + 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") + } + // Note: a commit ID file needs to exist at this point. - // Re-enable in DX-2307. - // Will have to pass the buildscript as an argument to this function. - //err = buildscript.Update(r.Project, expr, r.Auth) - //if err != nil { - // return locale.WrapError(err, "err_update_build_script") - //} + err = buildscript.Update(r.Project, expr, r.Auth) + if err != nil { + return locale.WrapError(err, "err_update_build_script") + } return nil } diff --git a/internal/runners/initialize/init.go b/internal/runners/initialize/init.go index ad1bf38430..d5561e63ac 100644 --- a/internal/runners/initialize/init.go +++ b/internal/runners/initialize/init.go @@ -21,6 +21,7 @@ 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" "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/platform/runtime/setup" @@ -161,11 +162,10 @@ func (r *Initialize) Run(params *RunParams) (rerr error) { } } - // Re-enable in DX-2307. - //emptyDir, err := fileutils.IsEmptyDir(path) - //if err != nil { - // multilog.Error("Unable to check if directory is empty: %v", err) - //} + 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,14 +247,13 @@ func (r *Initialize) Run(params *RunParams) (rerr error) { if err := commitmediator.Set(proj, commitID.String()); err != nil { return errs.Wrap(err, "Unable to create local commit file") } - // 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) - // } - //} + 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, r.config) if err != nil { diff --git a/internal/runners/pull/pull.go b/internal/runners/pull/pull.go index 8a13f0d201..ad37067ff4 100644 --- a/internal/runners/pull/pull.go +++ b/internal/runners/pull/pull.go @@ -1,6 +1,7 @@ package pull import ( + "errors" "path/filepath" "strings" @@ -21,7 +22,6 @@ import ( "github.com/ActiveState/cli/internal/runbits/commit" "github.com/ActiveState/cli/internal/runbits/commitmediator" bpModel "github.com/ActiveState/cli/pkg/platform/api/buildplanner/model" - "github.com/ActiveState/cli/pkg/platform/api/mono/mono_models" "github.com/ActiveState/cli/pkg/platform/authentication" "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/platform/runtime/buildexpression/merge" @@ -180,11 +180,10 @@ func (p *Pull) Run(params *PullParams) (rerr error) { } func (p *Pull) performMerge(remoteCommit, localCommit strfmt.UUID, namespace *project.Namespaced, branchName string, strategy bpModel.MergeStrategy) (strfmt.UUID, error) { - // 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") - //} + err := p.mergeBuildScript(remoteCommit, localCommit) + 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( @@ -218,9 +217,8 @@ func (p *Pull) performMerge(remoteCommit, localCommit strfmt.UUID, namespace *pr return resultCommit, nil } -// mergeBuildScript merges the local build script with the remote buildexpression (not script) for a -// given UUID, performing the given merge strategy (e.g. from model.MergeCommit). -func (p *Pull) mergeBuildScript(strategies *mono_models.MergeStrategies, remoteCommit strfmt.UUID) error { +// mergeBuildScript merges the local build script with the remote buildexpression (not script). +func (p *Pull) mergeBuildScript(remoteCommit, localCommit strfmt.UUID) error { // Get the build script to merge. script, err := buildscript.NewScriptFromProject(p.project, p.auth) if err != nil { @@ -235,6 +233,14 @@ func (p *Pull) mergeBuildScript(strategies *mono_models.MergeStrategies, remoteC return errs.Wrap(err, "Unable to get buildexpression for remote commit") } + // Compute the merge strategy. + strategies, err := model.MergeCommit(remoteCommit, localCommit) + if err != nil { + if !errors.Is(err, model.ErrMergeCommitInHistory) { + return locale.WrapError(err, "err_mergecommit", "Could not detect if merge is necessary.") + } + } + // Attempt the merge. mergedExpr, err := merge.Merge(exprA, exprB, strategies) if err != nil { diff --git a/internal/testhelpers/e2e/session.go b/internal/testhelpers/e2e/session.go index f654692166..26b8fb2580 100644 --- a/internal/testhelpers/e2e/session.go +++ b/internal/testhelpers/e2e/session.go @@ -41,7 +41,6 @@ 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 @@ -320,11 +319,7 @@ func (s *Session) PrepareActiveStateYAML(contents string) { } func (s *Session) PrepareCommitIdFile(commitID string) { - // 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)) + require.NoError(s.T, fileutils.WriteFile(filepath.Join(s.Dirs.Work, constants.ProjectConfigDirName, constants.CommitIdFileName), []byte(commitID))) } // PrepareProject creates a very simple activestate.yaml file for the given org/project and, if a diff --git a/pkg/platform/runtime/runtime.go b/pkg/platform/runtime/runtime.go index bade0c0c26..de4e3ecd32 100644 --- a/pkg/platform/runtime/runtime.go +++ b/pkg/platform/runtime/runtime.go @@ -120,8 +120,6 @@ 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 a4a2b9c397..d03d3d46cf 100644 --- a/pkg/platform/runtime/setup/setup.go +++ b/pkg/platform/runtime/setup/setup.go @@ -37,6 +37,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/envdef" "github.com/ActiveState/cli/pkg/platform/runtime/executors" "github.com/ActiveState/cli/pkg/platform/runtime/setup/buildlog" @@ -602,10 +603,9 @@ func (s *Setup) fetchAndInstallArtifactsFromBuildPlan(installFunc artifactInstal } if s.target.ProjectDir() != "" { - // 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.") - //} + if err := buildscript.Update(s.target, buildResult.BuildExpression, s.auth); err != nil { + return nil, nil, errs.Wrap(err, "Could not save build script.") + } } artifacts := buildResult.OrderedArtifacts() diff --git a/pkg/project/project.go b/pkg/project/project.go index 7ba4e219a6..85e849e315 100644 --- a/pkg/project/project.go +++ b/pkg/project/project.go @@ -219,12 +219,6 @@ 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 57bd0a392d..8df0240434 100644 --- a/pkg/project/project_test.go +++ b/pkg/project/project_test.go @@ -62,7 +62,6 @@ func (suite *ProjectTestSuite) TestGetSafe() { func (suite *ProjectTestSuite) TestProject() { 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 := commitmediator.Get(suite.project) diff --git a/pkg/project/testdata/activestate.yaml b/pkg/project/testdata/activestate.yaml index 80908d57b2..41f1f8d8ec 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&commitID=00010001-0001-0001-0001-000100010001 +project: https://platform.activestate.com/ActiveState/project?branch=main 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 fbf3da6c5c..f53555edb1 100644 --- a/pkg/projectfile/projectfield.go +++ b/pkg/projectfile/projectfield.go @@ -48,11 +48,6 @@ 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 d95956cd87..e0fba58ed9 100644 --- a/pkg/projectfile/projectfile.go +++ b/pkg/projectfile/projectfile.go @@ -564,25 +564,6 @@ 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) } @@ -934,17 +915,16 @@ 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 - LegacyCommitID string // remove in DX-2307 + Owner string + Project string + BranchName string + Directory string + Content string + Language string + Private bool + path string + ProjectURL string + Cache string } // Create will create a new activestate.yaml with a projectURL for the given details @@ -980,11 +960,6 @@ 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 c702856b2e..ddcd078273 100644 --- a/test/integration/checkout_int_test.go +++ b/test/integration/checkout_int_test.go @@ -40,13 +40,12 @@ 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. - // 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") + 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) @@ -155,10 +154,9 @@ func (suite *CheckoutIntegrationTestSuite) TestCheckoutWithFlags() { cp.ExpectExitCode(0) suite.Require().True(fileutils.DirExists(python3Dir), "state checkout should have created "+python3Dir) - // Re-enable the following lines in DX-2307. - //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") + 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/commit_int_test.go b/test/integration/commit_int_test.go index 57bf60d0fe..c58eba8230 100644 --- a/test/integration/commit_int_test.go +++ b/test/integration/commit_int_test.go @@ -20,7 +20,6 @@ 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/install_int_test.go b/test/integration/install_int_test.go index 5cb61da66c..66b8e1c69c 100644 --- a/test/integration/install_int_test.go +++ b/test/integration/install_int_test.go @@ -32,15 +32,13 @@ 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") // re-enable in DX-2307 - cp.Expect("Invalid commit ID") // remove in DX-2307 + cp.Expect("Could not find or read the commit file") cp.ExpectExitCode(1) ts.IgnoreLogErrors() - // Re-enable in DX-2307. - //if strings.Count(cp.Snapshot(), " x ") != 1 { - // suite.Fail("Expected exactly ONE error message, got: ", cp.Snapshot()) - //} + 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 494b081a42..a39c648f7a 100644 --- a/test/integration/project_migration_int_test.go +++ b/test/integration/project_migration_int_test.go @@ -18,7 +18,6 @@ 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 fcada61fd6..2fc5881c5a 100644 --- a/test/integration/pull_int_test.go +++ b/test/integration/pull_int_test.go @@ -15,7 +15,6 @@ import ( bpModel "github.com/ActiveState/cli/pkg/platform/api/buildplanner/model" "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" ) @@ -36,10 +35,9 @@ func (suite *PullIntegrationTestSuite) TestPull() { cp.Expect("activestate.yaml has been updated") cp.ExpectExitCode(0) - // 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))) + projectConfigDir := filepath.Join(ts.Dirs.Work, constants.ProjectConfigDirName) + suite.Require().True(fileutils.DirExists(projectConfigDir)) + suite.Assert().True(fileutils.FileExists(filepath.Join(projectConfigDir, constants.CommitIdFileName))) suite.assertMergeStrategyNotification(ts, string(bpModel.MergeCommitStrategyFastForward)) @@ -60,14 +58,9 @@ func (suite *PullIntegrationTestSuite) TestPull_Merge() { pjfilepath := filepath.Join(ts.Dirs.Work, "cli", constants.ConfigFileName) err := fileutils.WriteFile(pjfilepath, []byte(projectLine)) suite.Require().NoError(err) - // Remove the following lines in DX-2307. - pjfile, err := projectfile.Parse(pjfilepath) + commitIdFile := filepath.Join(ts.Dirs.Work, "cli", constants.ProjectConfigDirName, constants.CommitIdFileName) + err = fileutils.WriteFile(commitIdFile, []byte(unPulledCommit)) 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() @@ -94,7 +87,6 @@ func (suite *PullIntegrationTestSuite) TestPull_Merge() { 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() diff --git a/test/integration/push_int_test.go b/test/integration/push_int_test.go index b708512efb..c1cc4e1727 100644 --- a/test/integration/push_int_test.go +++ b/test/integration/push_int_test.go @@ -367,13 +367,8 @@ 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))) - // 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))) + 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))