@@ -2,7 +2,6 @@ package pull
22
33import (
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+
8592func (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.
0 commit comments