Skip to content

Commit fba05fb

Browse files
committed
Fixes the author used for merge commits.
1 parent c6664de commit fba05fb

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/git-split-file.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
# ------------------------------------------------------------------------------
1010
# @TODO: Add yes mode (-y / --yes) to run without questions
1111
# ------------------------------------------------------------------------------
12-
# @FIXME: Merge commit happens from the wrong author
13-
# ------------------------------------------------------------------------------
1412
# @FIXME: The cleanup gives errors if cleanup is run before/without the split being run
1513
# ------------------------------------------------------------------------------
1614
# @FIXME: Add "aggressive" mode that creates a commit on the source branch (?before/after? merge)
@@ -287,6 +285,20 @@ commit() {
287285
git commit --author="${GIT_AUTHOR}" --message="${1}."
288286
}
289287

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+
290302
createBranch() {
291303
local sBranchName sStartBranch
292304

@@ -352,8 +364,7 @@ mergeSplitBranch() {
352364
printStatus "Branch '${sBranchName}' exists"
353365

354366
(
355-
git merge --no-ff --no-edit -X theirs "${sBranchName}" \
356-
&& printStatus 'No merge conflict'
367+
git_merge "${sBranchName}" 'theirs' && printStatus 'No merge conflict'
357368
) || (
358369
printStatus 'Merge conflict occurred. Attempting to resolve.'
359370
git add -- "${g_sSourceFilePath}" \
@@ -560,7 +571,7 @@ run() {
560571
printTopic "Merging source branch '${g_sSourceBranch}' into the root branch '${g_sRootBranch}'"
561572
checkoutRootBranch
562573

563-
git merge --no-ff --no-edit "${g_sSourceBranch}"
574+
git_merge "${g_sSourceBranch}"
564575
else
565576
printMessage 'Aborting.'
566577
fi

0 commit comments

Comments
 (0)