MCPcopy Create free account
hub / github.com/daniellmb/angular-test-patterns / validateMessage

Function validateMessage

hooks/validate-commit-msg.js:35–74  ·  view source on GitHub ↗
(message)

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 1

errorFunction · 0.85

Tested by

no test coverage detected