@@ -25,8 +25,39 @@ func init() {
2525}
2626
2727func UpdateBranchCmd (command * handlers.Request , args string ) error {
28+ const (
29+ mergeText = `
30+ 🛠️ I failed to merge %s into your branch, you have to resolve conflicts manually
31+
32+ <details>
33+ <summary>
34+ How to merge branch manually:
35+ </summary>
36+ <pre><code>git checkout %s
37+ git pull origin
38+ git checkout %s
39+ git merge %s
40+ # resolve conflicts
41+ git push origin</code></pre>
42+
43+ </details>
44+ `
45+ )
2846 if err := command .UpdateFromMaster (); err != nil {
2947 logger .Info ("command.UpdateFromMaster failed" , "error" , err )
48+ mergeError := & handlers.MergeError {}
49+ if errors .As (err , & mergeError ) {
50+ text := fmt .Sprintf (
51+ mergeText ,
52+ mergeError .DestinationBranch ,
53+ mergeError .DestinationBranch ,
54+ mergeError .SourceBranch ,
55+ mergeError .DestinationBranch ,
56+ )
57+
58+ return command .LeaveComment (text )
59+ }
60+
3061 return command .LeaveComment ("❌ i couldn't update the branch from the destination" )
3162 }
3263
@@ -39,7 +70,7 @@ func MergeCmd(command *handlers.Request, args string) error {
3970 return fmt .Errorf ("command.Merge returns err: %w" , err )
4071 }
4172
42- if ! ok && len ( text ) > 0 {
73+ if ! ok {
4374 return command .LeaveComment (text )
4475 }
4576 return err
@@ -51,7 +82,7 @@ func CheckCmd(command *handlers.Request, args string) error {
5182 return fmt .Errorf ("command.IsValid returns err: %w" , err )
5283 }
5384
54- if ! ok && len ( text ) > 0 {
85+ if ! ok {
5586 return command .LeaveComment (text )
5687 } else {
5788 return command .LeaveComment ("You can merge, LGTM :D" )
0 commit comments