1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
|
package shared
import (
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var OriginalFileContent = `
This
Is
The
Original
File
`
var FirstChangeFileContent = `
This
Is
The
First Change
File
`
var SecondChangeFileContent = `
This
Is
The
Second Change
File
`
// prepares us for a rebase/merge that has conflicts
var MergeConflictsSetup = func(shell *Shell) {
shell.
NewBranch("original-branch").
EmptyCommit("one").
EmptyCommit("two").
EmptyCommit("three").
CreateFileAndAdd("file", OriginalFileContent).
Commit("original").
NewBranch("first-change-branch").
UpdateFileAndAdd("file", FirstChangeFileContent).
Commit("first change").
Checkout("original-branch").
NewBranch("second-change-branch").
UpdateFileAndAdd("file", SecondChangeFileContent).
Commit("second change").
EmptyCommit("second-change-branch unrelated change").
Checkout("first-change-branch")
}
var CreateMergeConflictFile = func(shell *Shell) {
MergeConflictsSetup(shell)
shell.RunCommandExpectError([]string{"git", "merge", "--no-edit", "second-change-branch"})
}
var CreateMergeCommit = func(shell *Shell) {
CreateMergeConflictFile(shell)
shell.UpdateFileAndAdd("file", SecondChangeFileContent)
shell.ContinueMerge()
}
// creates a merge conflict where there are two files with conflicts and a separate file without conflicts
var CreateMergeConflictFiles = func(shell *Shell) {
shell.
NewBranch("original-branch").
EmptyCommit("one").
EmptyCommit("two").
EmptyCommit("three").
CreateFileAndAdd("file1", OriginalFileContent).
CreateFileAndAdd("file2", OriginalFileContent).
Commit("original").
NewBranch("first-change-branch").
UpdateFileAndAdd("file1", FirstChangeFileContent).
UpdateFileAndAdd("file2", FirstChangeFileContent).
Commit("first change").
Checkout("original-branch").
NewBranch("second-change-branch").
UpdateFileAndAdd("file1", SecondChangeFileContent).
UpdateFileAndAdd("file2", SecondChangeFileContent).
// this file is not changed in the second branch
CreateFileAndAdd("file3", "content").
Commit("second change").
EmptyCommit("second-change-branch unrelated change").
Checkout("first-change-branch")
shell.RunCommandExpectError([]string{"git", "merge", "--no-edit", "second-change-branch"})
}
// These 'multiple' variants are just like the short ones but with longer file contents and with multiple conflicts within the file.
var OriginalFileContentMultiple = `
This
Is
The
Original
File
..
It
Is
Longer
Than
The
Other
Options
`
var FirstChangeFileContentMultiple = `
This
Is
The
First Change
File
..
It
Is
Longer
Than
The
Other
Other First Change
`
var SecondChangeFileContentMultiple = `
This
Is
The
Second Change
File
..
It
Is
Longer
Than
The
Other
Other Second Change
`
var CreateMergeConflictFileMultiple = func(shell *Shell) {
shell.
NewBranch("original-branch").
EmptyCommit("one").
EmptyCommit("two").
EmptyCommit("three").
CreateFileAndAdd("file", OriginalFileContentMultiple).
Commit("original").
NewBranch("first-change-branch").
UpdateFileAndAdd("file", FirstChangeFileContentMultiple).
Commit("first change").
Checkout("original-branch").
NewBranch("second-change-branch").
UpdateFileAndAdd("file", SecondChangeFileContentMultiple).
Commit("second change").
EmptyCommit("second-change-branch unrelated change").
Checkout("first-change-branch")
shell.RunCommandExpectError([]string{"git", "merge", "--no-edit", "second-change-branch"})
}
var CreateMergeConflictFileForMergeFileTests = func(shell *Shell, originalFileContent string, currentChangeFileContent string, incomingChangeFileContent string) {
shell.
NewBranch("original-branch").
EmptyCommit("one").
CreateFileAndAdd("file", originalFileContent).
Commit("original").
NewBranch("current-change-branch").
UpdateFileAndAdd("file", currentChangeFileContent).
Commit("first change").
Checkout("original-branch").
NewBranch("incoming-change-branch").
UpdateFileAndAdd("file", incomingChangeFileContent).
Commit("second change").
Checkout("current-change-branch").
RunCommandExpectError([]string{"git", "merge", "--no-edit", "incoming-change-branch"})
}
|