mirror of
https://github.com/affaan-m/ECC.git
synced 2026-11-07 16:45:53 +00:00
fix(hooks): treat only backslash-LF as a line continuation in a commit message
Bash removes a backslash before a newline, but not one before a carriage return. Removing backslash-CRLF joined two lines of the message, and their text was then read as the subject.
This commit is contained in:
2 files changed
+4
-2
No files matched your search
@@ -206,7 +206,7 @@ function validateCommitMessage(command) {
|
||||
: null;
|
||||
// In double quotes, Bash drops the backslash before $ ` " \ and drops a backslash-newline,
|
||||
// a line continuation, altogether. Before any other character the backslash stays.
|
||||
const doubleQuoted = messageMatch[1]?.replace(/\\(\r?\n|[$`"\\])/g, (escape, next) => (next.endsWith('\n') ? '' : next));
|
||||
const doubleQuoted = messageMatch[1]?.replace(/\\([\n$`"\\])/g, (escape, next) => (next === '\n' ? '' : next));
|
||||
const message = heredoc ?? doubleQuoted ?? messageMatch[2] ?? messageMatch[3];
|
||||
// The format rules apply to the subject: git drops leading blank lines and trailing
|
||||
// whitespace, and the first line left is the subject.
|
||||
|
||||
Reference in new issue
Block a user