|
9 | 9 | # ------------------------------------------------------------------------------ |
10 | 10 | # @TODO: Add yes mode (-y / --yes) to run without questions |
11 | 11 | # ------------------------------------------------------------------------------ |
12 | | -# @FIXME: Merge commit happens from the wrong author |
13 | | -# ------------------------------------------------------------------------------ |
14 | 12 | # @FIXME: The cleanup gives errors if cleanup is run before/without the split being run |
15 | 13 | # ------------------------------------------------------------------------------ |
16 | 14 | # @FIXME: Add "aggressive" mode that creates a commit on the source branch (?before/after? merge) |
@@ -287,6 +285,20 @@ commit() { |
287 | 285 | git commit --author="${GIT_AUTHOR}" --message="${1}." |
288 | 286 | } |
289 | 287 |
|
| 288 | +git_merge() { |
| 289 | + |
| 290 | + local -r sBranch="${1?One parameter required: <branch> [merge-strategy]}" |
| 291 | + local -r sMergeStrategy="${2:-}" |
| 292 | + |
| 293 | + if [[ "${sMergeStrategy}" == '' ]];then |
| 294 | + git merge --no-ff --no-edit "${sBranch}" |
| 295 | + else |
| 296 | + git merge --no-ff --no-edit -X "${sMergeStrategy}" "${sBranch}" |
| 297 | + fi |
| 298 | + |
| 299 | + git commit --amend --author="${GIT_AUTHOR}" --no-edit |
| 300 | +} |
| 301 | + |
290 | 302 | createBranch() { |
291 | 303 | local sBranchName sStartBranch |
292 | 304 |
|
@@ -352,8 +364,7 @@ mergeSplitBranch() { |
352 | 364 | printStatus "Branch '${sBranchName}' exists" |
353 | 365 |
|
354 | 366 | ( |
355 | | - git merge --no-ff --no-edit -X theirs "${sBranchName}" \ |
356 | | - && printStatus 'No merge conflict' |
| 367 | + git_merge "${sBranchName}" 'theirs' && printStatus 'No merge conflict' |
357 | 368 | ) || ( |
358 | 369 | printStatus 'Merge conflict occurred. Attempting to resolve.' |
359 | 370 | git add -- "${g_sSourceFilePath}" \ |
@@ -560,7 +571,7 @@ run() { |
560 | 571 | printTopic "Merging source branch '${g_sSourceBranch}' into the root branch '${g_sRootBranch}'" |
561 | 572 | checkoutRootBranch |
562 | 573 |
|
563 | | - git merge --no-ff --no-edit "${g_sSourceBranch}" |
| 574 | + git_merge "${g_sSourceBranch}" |
564 | 575 | else |
565 | 576 | printMessage 'Aborting.' |
566 | 577 | fi |
|
0 commit comments