Skip to content

Commit 8c66074

Browse files
committed
format commit message with new lines
1 parent bee7127 commit 8c66074

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed
Binary file not shown.

gitcom/Commands/IntegrateCommand.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ Add command to your system for creating beautiful commit (`gitcom`)
1919
var commitMessageHook: String = """
2020
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
2121
message=`cat $1`
22-
messageWithNewLines=${message//|/"\\n"}
22+
messageWithNewLine=${message//|/"\\n"}
23+
echo "$messageWithNewLine" > "$1"
2324
gitcom validate "$message"
2425
"""
25-
26+
2627
private func copyExecutableToBinFolder() {
2728
let executableURLinBin = URL(fileURLWithPath: "/usr/local/bin" + Constants.executableNamePath)
2829
let currentDirPath = FileManager.default.currentDirectoryPath
@@ -58,7 +59,7 @@ gitcom validate "$message"
5859

5960
private func appendValidationHook(sampleFilePath: String, hookFilePath: String) {
6061
guard let data = commitMessageHook.data(using: .utf8, allowLossyConversion: false) else { return }
61-
62+
6263
if FileManager.default.fileExists(atPath: hookFilePath) {
6364
if let fileHandle = FileHandle(forWritingAtPath: hookFilePath) {
6465
fileHandle.seekToEndOfFile()

gitcom/Commands/ValidateCommand.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Add message as parameter.
184184
footer += part
185185
}
186186
}
187-
guard validateBody(bodySettings: config.body, body: body/*, footerSettings: config.footer*/),
187+
guard validateBody(bodySettings: config.body, body: body),
188188
validateFooter(footerSettings: config.footer, footer: footer)
189189
else {
190190
return false
@@ -216,13 +216,11 @@ Add message as parameter.
216216
var parts = arguments.first?.trimmingCharacters(in: .whitespacesAndNewlines).split(separator: "|")
217217
if let commitParts = parts, commitParts.count > 1 {
218218
processCommitParts(parts: commitParts)
219-
print("\("Commit message is valid".color(.green))\("".color(.default))")
220219
}
221220
else {
222221
parts = arguments.first?.trimmingCharacters(in: .whitespacesAndNewlines).split(separator: "\n")
223222
if let commitParts = parts, commitParts.count > 1 {
224223
processCommitParts(parts: commitParts)
225-
print("\("Commit message is valid".color(.green))\("".color(.default))")
226224
}
227225
else {
228226
print(error(errorMessage: "Commit message does not exist"))

0 commit comments

Comments
 (0)