Skip to content

Commit 6123e3a

Browse files
committed
Fix issue with multi-line commit messages
1 parent fbb1079 commit 6123e3a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ plugins {
1212
}
1313

1414
group = 'net.minecrell'
15-
version = '0.4.1'
15+
version = '0.4.2'
1616
description = 'A Gradle plugin to manage patches for Git repositories'
1717

1818
sourceCompatibility = 1.6

src/main/groovy/net/minecrell/gitpatcher/git/MailPatch.groovy

+7-2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ class MailPatch {
7474
continue
7575
}
7676

77+
line = line.trim()
78+
7779
if (line.startsWith('diff')) {
7880
break
7981
}
@@ -97,7 +99,9 @@ class MailPatch {
9799
builder = new StringBuilder(StringUtils.removeStart(content, '[PATCH] '))
98100
}
99101
} else {
100-
builder << line.trim()
102+
if (!line.empty) {
103+
builder << '\n' << line
104+
}
101105
}
102106
}
103107

@@ -143,7 +147,8 @@ class MailPatch {
143147
dateFormat.printTo writer, new DateTime(commit.authorIdent.getWhen(), DateTimeZone.forTimeZone(commit.authorIdent.timeZone))
144148
writer << '\n'
145149

146-
writer << 'Subject: [PATCH] ' << commit.fullMessage << '\n\n\n'
150+
def message = commit.fullMessage
151+
writer << 'Subject: [PATCH] ' << message << (message.endsWith('\n') ? '\n\n' : '\n\n\n')
147152
writer.flush()
148153
}
149154

0 commit comments

Comments
 (0)