(message)
| 42 | |
| 43 | |
| 44 | var validateMessage = function(message) { |
| 45 | var isValid = true; |
| 46 | |
| 47 | if (IGNORED.test(message)) { |
| 48 | console.log('Commit message validation ignored.'); |
| 49 | return true; |
| 50 | } |
| 51 | |
| 52 | if (message.length > MAX_LENGTH) { |
| 53 | error('is longer than %d characters !', MAX_LENGTH); |
| 54 | isValid = false; |
| 55 | } |
| 56 | |
| 57 | match = PATTERN.exec(message); |
| 58 | |
| 59 | if (!match) { |
| 60 | error('does not match "<type>(<scope>): <subject>" ! was: "' + message + '"\nNote: <scope> must be only letters.'); |
| 61 | return false; |
| 62 | } |
| 63 | |
| 64 | type = match[1]; |
| 65 | // scope = match[3]; |
| 66 | // subject = match[4]; |
| 67 | |
| 68 | if (!TYPES.hasOwnProperty(type)) { |
| 69 | error('"%s" is not allowed type !', type); |
| 70 | return false; |
| 71 | } |
| 72 | |
| 73 | // Some more ideas, do want anything like this ? |
| 74 | // - allow only specific scopes (eg. fix(docs) should not be allowed ? |
| 75 | // - auto correct the type to lower case ? |
| 76 | // - auto correct first letter of the subject to lower case ? |
| 77 | // - auto add empty line after subject ? |
| 78 | // - auto remove empty () ? |
| 79 | // - auto correct typos in type ? |
| 80 | // - store incorrect messages, so that we can learn |
| 81 | |
| 82 | return isValid; |
| 83 | }; |
| 84 | |
| 85 | |
| 86 | var firstLineFromBuffer = function(buffer) { |
no test coverage detected