Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

State revert uses the build planner #2858

Merged
merged 7 commits into from
Nov 3, 2023
Merged

State revert uses the build planner #2858

merged 7 commits into from
Nov 3, 2023

Conversation

MDrakos
Copy link
Member

@MDrakos MDrakos commented Oct 30, 2023

StoryDX-2226 `state revert --to` uses the BuildPlanner

@github-actions github-actions bot changed the base branch from master to version/0-42-0-RC1 October 30, 2023 20:45
@MDrakos MDrakos requested a review from mitchell-as November 2, 2023 21:41
Copy link
Contributor

@mitchell-as mitchell-as left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks great. A few things to tweak though, I think.

@@ -1703,7 +1703,7 @@ err_user_network_solution:
err_revert_get_commit:
other: "Could not fetch commit details for commit with ID: {{.V0}}"
err_revert_commit:
other: "Could not revert{{.V0}} commit: {{.V1}}"
other: "Could not revert {{.V0}} commit: {{.V1}}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lack of space was intentional so that we could have Could not revert commit: X or Could not revert to commit: X (see https://github.com/ActiveState/cli/pull/2858/files#diff-b6b503d1d2e8bd95d174c9cf7c989b67e26bb91a2882e96cb6a916cafc55fbc1R85). Now it could be Could not revert commit: X (note the two spaces). Unless I'm missing something, please revert this change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh okay, thanks for catching that!

func (r *Revert) revertCommit(params revertParams, bp *model.BuildPlanner) (strfmt.UUID, error) {
newCommitID, err := bp.RevertCommit(params.organization, params.project, params.parentCommitID, params.revertCommitID)
if err != nil {
return "", errs.Wrap(err, "could not revert commit")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: capitalize "Could"

func (r *Revert) revertToCommit(params revertParams, bp *model.BuildPlanner) (strfmt.UUID, error) {
buildExpression, err := bp.GetBuildExpression(params.organization, params.project, params.revertCommitID)
if err != nil {
return "", errs.Wrap(err, "could not get build expression")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: capitalize "Could"

@@ -0,0 +1,79 @@
package request
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I understand this now!

resp := &bpModel.RevertCommitResult{}
err := bp.client.Run(request.RevertCommit(organization, project, parentCommitID, commitID), resp)
if err != nil {
return "", processBuildPlannerError(err, "failed to revert commit")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: capitalize "Failed"?

@@ -115,7 +115,6 @@ func (suite *RevertIntegrationTestSuite) TestRevertTo() {
e2e.OptArgs("history"),
e2e.OptWD(wd),
)
cp.Expect("Reverting to commit " + commitID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is printed to the user in this case? Should we be asserting it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, this is actually the commit message that is now different with the buildplanner

Comment on lines +127 to +134
err = commitmediator.Set(r.project, revertCommit.String())
if err != nil {
return locale.WrapError(err, "err_refresh_runtime")
return errs.Wrap(err, "Unable to set local commit")
}

err = commitmediator.Set(r.project, revertCommit.CommitID.String())
err = runbits.RefreshRuntime(r.auth, r.out, r.analytics, r.project, revertCommit, true, target.TriggerRevert, r.svcModel)
if err != nil {
return errs.Wrap(err, "Unable to set local commit")
return locale.WrapError(err, "err_refresh_runtime")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call to swap these two.


newCommitID, err := bp.StageCommit(stageCommitParams)
if err != nil {
return "", errs.Wrap(err, "could not stage commit")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: capitalize "Could"

@@ -408,6 +415,18 @@ type CreateProjectResult struct {
ProjectCreated *projectCreated `json:"createProject"`
}

type RevertedCommit struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this type need to be public? The mergedCommit type below on line 430 is similar in function and private.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it can be private

Capitalize error messages
Add back expect line
@MDrakos MDrakos requested a review from mitchell-as November 2, 2023 23:01
cp.Expect("- argparse") // effectively reverting previous commit
cp.Expect("+ argparse") // commit being effectively reverted
cp.Expect("+ urllib3") // commit reverted to
cp.Expect("+ python") // initial commit
fmt.Println("Output: ", cp.Snapshot())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was accidentally left here instead of removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, thanks for catching that!

@MDrakos MDrakos merged commit 898e6fd into version/0-42-0-RC1 Nov 3, 2023
7 checks passed
@MDrakos MDrakos deleted the DX-2226 branch November 3, 2023 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants