From 6e132efb58ffef09be43fee7b9636bcd4b64ab3d Mon Sep 17 00:00:00 2001 From: Andrew Oberstar Date: Sat, 2 Jan 2016 16:42:48 -0600 Subject: [PATCH] Adding tests for #93 and #94 --- .../grgit/operation/MergeOpSpec.groovy | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/test/groovy/org/ajoberstar/grgit/operation/MergeOpSpec.groovy b/src/test/groovy/org/ajoberstar/grgit/operation/MergeOpSpec.groovy index 8f36028e..ba9b944b 100644 --- a/src/test/groovy/org/ajoberstar/grgit/operation/MergeOpSpec.groovy +++ b/src/test/groovy/org/ajoberstar/grgit/operation/MergeOpSpec.groovy @@ -161,4 +161,55 @@ class MergeOpSpec extends MultiGitOpSpec { 'origin/conflict' | SQUASH 'origin/conflict' | NO_COMMIT } + + def 'merge uses message if supplied'() { + given: + def oldHead = localGrgit.head() + def mergeHead = remoteGrgit.resolve.toCommit('clean') + when: + localGrgit.merge(head: 'origin/clean', message: 'Custom message') + then: 'all changes are committed' + localGrgit.status().clean + and: 'a merge commit was created' + localGrgit.log { + includes = ['HEAD'] + excludes = [oldHead.id, mergeHead.id] + }.size() == 1 + and: 'the merge commits message is what was passed in' + localGrgit.head().shortMessage == 'Custom message' + } + + def 'merge of a branch includes this in default message'() { + given: + def oldHead = localGrgit.head() + def mergeHead = remoteGrgit.resolve.toCommit('clean') + when: + localGrgit.merge(head: 'origin/clean') + then: 'all changes are committed' + localGrgit.status().clean + and: 'a merge commit was created' + localGrgit.log { + includes = ['HEAD'] + excludes = [oldHead.id, mergeHead.id] + }.size() == 1 + and: 'the merge commits message mentions branch name' + localGrgit.head().shortMessage == 'Merge branch origin/clean into merge-test' + } + + def 'merge of a commit includes this in default message'() { + given: + def oldHead = localGrgit.head() + def mergeHead = remoteGrgit.resolve.toCommit('clean') + when: + localGrgit.merge(head: mergeHead.id) + then: 'all changes are committed' + localGrgit.status().clean + and: 'a merge commit was created' + localGrgit.log { + includes = ['HEAD'] + excludes = [oldHead.id, mergeHead.id] + }.size() == 1 + and: 'the merge commits message mentions commit hash' + localGrgit.head().shortMessage == "Merge commit '${mergeHead.id}' into merge-test" + } }