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