Skip to content

Commit bbb3104

Browse files
committed
Merge remote-tracking branch 'origin/version/0-44-0-RC5' into beta
2 parents f3ecdaf + b2995ee commit bbb3104

File tree

6 files changed

+39
-16
lines changed

6 files changed

+39
-16
lines changed

cmd/state/internal/cmdtree/manifest.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func newManifestCommmand(prime *primer.Values) *captain.Command {
2424

2525
cmd.SetGroup(PackagesGroup)
2626
cmd.SetSupportsStructuredOutput()
27+
cmd.SetUnstable(true)
2728

2829
return cmd
2930
}

internal/locale/locales/en-us.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ err_initial_no_requirement:
15941594
To check for available packages run '[ACTIONABLE]state search <package_name>[/RESET]'.
15951595
manifest_deprecation_warning:
15961596
other: |
1597-
[WARNING]Warning:[/RESET] This command is deprecated, please use '[ACTIONABLE]state manfiest[/RESET]' instead.
1597+
[WARNING]Warning:[/RESET] This command is deprecated, please use '[ACTIONABLE]state manifest[/RESET]' instead.
15981598
manifest_runtime_needs_update:
15991599
other: "[WARNING]WARNING:[/RESET] Your runtime is out of date, in order to ensure an accurate manifest please run [ACTIONABLE]state refresh[/RESET].\n"
16001600
vulnerability_critical:

internal/runners/pull/pull.go

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package pull
22

33
import (
44
"errors"
5-
"path/filepath"
65
"strings"
76
"time"
87

@@ -82,6 +81,14 @@ func (o *pullOutput) MarshalStructured(format output.Format) interface{} {
8281
return o
8382
}
8483

84+
type ErrBuildScriptMergeConflict struct {
85+
ProjectDir string
86+
}
87+
88+
func (e *ErrBuildScriptMergeConflict) Error() string {
89+
return "build script merge conflict"
90+
}
91+
8592
func (p *Pull) Run(params *PullParams) (rerr error) {
8693
defer rationalizeError(&rerr)
8794

@@ -157,18 +164,24 @@ func (p *Pull) Run(params *PullParams) (rerr error) {
157164
}
158165

159166
if commitID != *resultingCommit {
160-
err := localcommit.Set(p.project.Dir(), resultingCommit.String())
161-
if err != nil {
162-
return errs.Wrap(err, "Unable to set local commit")
163-
}
164-
165167
if p.cfg.GetBool(constants.OptinBuildscriptsConfig) {
166168
err := p.mergeBuildScript(*remoteCommit, *localCommit)
167169
if err != nil {
170+
if errs.Matches(err, &ErrBuildScriptMergeConflict{}) {
171+
err2 := localcommit.Set(p.project.Dir(), remoteCommit.String())
172+
if err2 != nil {
173+
err = errs.Pack(err, errs.Wrap(err2, "Could not set local commit to remote commit after build script merge conflict"))
174+
}
175+
}
168176
return errs.Wrap(err, "Could not merge local build script with remote changes")
169177
}
170178
}
171179

180+
err := localcommit.Set(p.project.Dir(), resultingCommit.String())
181+
if err != nil {
182+
return errs.Wrap(err, "Unable to set local commit")
183+
}
184+
172185
p.out.Print(&pullOutput{
173186
locale.Tr("pull_updated", remoteProject.String(), resultingCommit.String()),
174187
true,
@@ -260,10 +273,7 @@ func (p *Pull) mergeBuildScript(remoteCommit, localCommit strfmt.UUID) error {
260273
if err != nil {
261274
return locale.WrapError(err, "err_diff_build_script", "Unable to generate differences between local and remote build script")
262275
}
263-
return locale.NewInputError(
264-
"err_build_script_merge",
265-
"Unable to automatically merge build scripts. Please resolve conflicts manually in '{{.V0}}' and then run '[ACTIONABLE]state commit[/RESET]'",
266-
filepath.Join(p.project.Dir(), constants.BuildScriptFileName))
276+
return &ErrBuildScriptMergeConflict{p.project.Dir()}
267277
}
268278

269279
// For now, pick the later of the script AtTimes.

internal/runners/pull/rationalize.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package pull
22

33
import (
44
"errors"
5+
"path/filepath"
56

7+
"github.com/ActiveState/cli/internal/constants"
68
"github.com/ActiveState/cli/internal/errs"
79
"github.com/ActiveState/cli/internal/locale"
810
"github.com/ActiveState/cli/pkg/platform/api/buildplanner/model"
@@ -14,6 +16,7 @@ func rationalizeError(err *error) {
1416
}
1517

1618
var mergeCommitErr *model.MergedCommitError
19+
var buildscriptMergeCommitErr *ErrBuildScriptMergeConflict
1720

1821
switch {
1922
case errors.As(*err, &mergeCommitErr):
@@ -44,5 +47,12 @@ func rationalizeError(err *error) {
4447
),
4548
)
4649
}
50+
51+
case errors.As(*err, &buildscriptMergeCommitErr):
52+
*err = errs.WrapUserFacing(*err,
53+
locale.Tl("err_build_script_merge",
54+
"Unable to automatically merge build scripts. Please resolve conflicts manually in '{{.V0}}' and then run '[ACTIONABLE]state commit[/RESET]'",
55+
filepath.Join(buildscriptMergeCommitErr.ProjectDir, constants.BuildScriptFileName)),
56+
errs.SetInput())
4757
}
4858
}

test/integration/pull_int_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,14 @@ func (suite *PullIntegrationTestSuite) TestMergeBuildScript() {
114114
suite.Assert().Contains(string(bytes), "=======", "No merge conflict markers are in build script")
115115
suite.Assert().Contains(string(bytes), ">>>>>>>", "No merge conflict markers are in build script")
116116

117-
// Verify the local commit was updated to the merge commit.
118-
// Note: even though the buildscript merge failed, a merge commit was still created. After resolving
119-
// buildscript conflicts, `state commit` should have something new to commit.
117+
// Verify the local commit was updated to the remote commit, not the merge commit.
118+
// Note: even though the buildscript merge failed, a merge commit was still created (we just
119+
// ignore it). After resolving buildscript conflicts, `state commit` should always have something
120+
// new to commit.
121+
remoteHeadCommit := "d908a758-6a81-40d4-b0eb-87069cd7f07d"
120122
commit, err := localcommit.Get(ts.Dirs.Work)
121123
suite.Require().NoError(err)
122-
suite.Assert().NotEqual(commit.String(), "447b8363-024c-4143-bf4e-c96989314fdf", "localcommit not updated to merged commit")
124+
suite.Assert().Equal(remoteHeadCommit, commit.String(), "localcommit should have been updated to remote commit")
123125
}
124126

125127
func (suite *PullIntegrationTestSuite) assertMergeStrategyNotification(ts *e2e.Session, strategy string) {

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.44.0-RC4
1+
0.44.0-RC5

0 commit comments

Comments
 (0)