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
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/locale/locales/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}"
install_initial_success:
other: "An activestate.yaml has been created at: {{.V0}}."
err_package_info_no_packages:
Expand Down
6 changes: 3 additions & 3 deletions internal/runners/revert/revert.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ type revertParams struct {
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")
return "", errs.Wrap(err, "Could not revert commit")
}

return newCommitID, nil
Expand All @@ -167,7 +167,7 @@ func (r *Revert) revertCommit(params revertParams, bp *model.BuildPlanner) (strf
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")
return "", errs.Wrap(err, "Could not get build expression")
}

stageCommitParams := model.StageCommitParams{
Expand All @@ -180,7 +180,7 @@ func (r *Revert) revertToCommit(params revertParams, bp *model.BuildPlanner) (st

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

return newCommitID, nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/platform/api/buildplanner/model/buildplan.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ type CreateProjectResult struct {
ProjectCreated *projectCreated `json:"createProject"`
}

type RevertedCommit struct {
type revertedCommit struct {
Type string `json:"__typename"`
Commit *Commit `json:"commit"`
CommonAncestor strfmt.UUID `json:"commonAncestorID"`
Expand All @@ -424,7 +424,7 @@ type RevertedCommit struct {
}

type RevertCommitResult struct {
RevertedCommit *RevertedCommit `json:"revertCommit"`
RevertedCommit *revertedCommit `json:"revertCommit"`
}

type mergedCommit struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/platform/model/buildplanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func (bp *BuildPlanner) RevertCommit(organization, project, parentCommitID, comm
resp := &bpModel.RevertCommitResult{}
err := bp.client.Run(request.RevertCommit(organization, project, parentCommitID, commitID), resp)
if err != nil {
return "", processBuildPlannerError(err, "failed to revert commit")
return "", processBuildPlannerError(err, "Failed to revert commit")
}

if resp.RevertedCommit == nil {
Expand Down
2 changes: 2 additions & 0 deletions test/integration/revert_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,12 @@ func (suite *RevertIntegrationTestSuite) TestRevertTo() {
e2e.OptArgs("history"),
e2e.OptWD(wd),
)
cp.Expect("Revert to commit " + commitID)
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!

}

func (suite *RevertIntegrationTestSuite) TestRevertTo_failsOnCommitNotInHistory() {
Expand Down
Loading