Skip to content

Commit b00cfa9

Browse files
committed
Do not update to merge commit if there was a buildscript conflict.
This partially reverts ActiveState#3249 because that solution was based on the buggy behavior fixed in ActiveState#3282.
1 parent efff2c2 commit b00cfa9

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

internal/runners/pull/pull.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,18 @@ func (p *Pull) Run(params *PullParams) (rerr error) {
157157
}
158158

159159
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-
165160
if p.cfg.GetBool(constants.OptinBuildscriptsConfig) {
166161
err := p.mergeBuildScript(*remoteCommit, *localCommit)
167162
if err != nil {
168163
return errs.Wrap(err, "Could not merge local build script with remote changes")
169164
}
170165
}
171166

167+
err := localcommit.Set(p.project.Dir(), resultingCommit.String())
168+
if err != nil {
169+
return errs.Wrap(err, "Unable to set local commit")
170+
}
171+
172172
p.out.Print(&pullOutput{
173173
locale.Tr("pull_updated", remoteProject.String(), resultingCommit.String()),
174174
true,

test/integration/pull_int_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ func (suite *PullIntegrationTestSuite) TestMergeBuildScript() {
9494
cp.Expect("Package added", e2e.RuntimeSourcingTimeoutOpt)
9595
cp.ExpectExitCode(0)
9696

97+
commit, err := localcommit.Get(ts.Dirs.Work)
98+
suite.Require().NoError(err)
99+
97100
proj, err := project.FromPath(ts.Dirs.Work)
98101
suite.NoError(err, "Error loading project")
99102

@@ -114,12 +117,12 @@ func (suite *PullIntegrationTestSuite) TestMergeBuildScript() {
114117
suite.Assert().Contains(string(bytes), "=======", "No merge conflict markers are in build script")
115118
suite.Assert().Contains(string(bytes), ">>>>>>>", "No merge conflict markers are in build script")
116119

117-
// Verify the local commit was updated to the merge commit.
120+
// Verify the local commit was not updated to the merge commit.
118121
// 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.
120-
commit, err := localcommit.Get(ts.Dirs.Work)
122+
// buildscript conflicts, `state commit` should always have something new to commit.
123+
commit2, err := localcommit.Get(ts.Dirs.Work)
121124
suite.Require().NoError(err)
122-
suite.Assert().NotEqual(commit.String(), "447b8363-024c-4143-bf4e-c96989314fdf", "localcommit not updated to merged commit")
125+
suite.Assert().Equal(commit.String(), commit2.String(), "localcommit should not have been updated to merged commit")
123126
}
124127

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

0 commit comments

Comments
 (0)