8000 angular.js/validate-commit-msg.js at master · drewp/angular.js · GitHub
[go: up one dir, main page]

Skip to content
{"payload":{"allShortcutsEnabled":false,"fileTree":{"":{"items":[{"name":"closure","path":"closure","contentType":"directory"},{"name":"css","path":"css","contentType":"directory"},{"name":"docs","path":"docs","contentType":"directory"},{"name":"example","path":"example","contentType":"directory"},{"name":"i18n","path":"i18n","contentType":"directory"},{"name":"images","path":"images","contentType":"directory"},{"name":"lib","path":"lib","contentType":"directory"},{"name":"logs","path":"logs","contentType":"directory"},{"name":"scripts","path":"scripts","contentType":"directory"},{"name":"src","path":"src","contentType":"directory"},{"name":"test","path":"test","contentType":"directory"},{"name":".bowerrc","path":".bowerrc","contentType":"file"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".travis.yml","path":".travis.yml","contentType":"file"},{"name":"CHANGELOG.md","path":"CHANGELOG.md","contentType":"file"},{"name":"CONTRIBUTING.md","path":"CONTRIBUTING.md","contentType":"file"},{"name":"Gruntfile.js","path":"Gruntfile.js","contentType":"file"},{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"TRIAGING.md","path":"TRIAGING.md","contentType":"file"},{"name":"angularFiles.js","path":"angularFiles.js","contentType":"file"},{"name":"bower.json","path":"bower.json","contentType":"file"},{"name":"changelog.js","path":"changelog.js","contentType":"file"},{"name":"changelog.spec.js","path":"changelog.spec.js","contentType":"file"},{"name":"check-size.sh","path":"check-size.sh","contentType":"file"},{"name":"compare-master-to-stable.js","path":"compare-master-to-stable.js","contentType":"file"},{"name":"gdocs.js","path":"gdocs.js","contentType":"file"},{"name":"gen_docs.sh","path":"gen_docs.sh","contentType":"file"},{"name":"init-repo.sh","path":"init-repo.sh","contentType":"file"},{"name":"jenkins_build.sh","path":"jenkins_build.sh","contentType":"file"},{"name":"karma-docs.conf.js","path":"karma-docs.conf.js","contentType":"file"},{"name":"karma-e2e.conf.js","path":"karma-e2e.conf.js","contentType":"file"},{"name":"karma-jqlite.conf.js","path":"karma-jqlite.conf.js","contentType":"file"},{"name":"karma-jquery.conf.js","path":"karma-jquery.conf.js","contentType":"file"},{"name":"karma-modules.conf.js","path":"karma-modules.conf.js","contentType":"file"},{"name":"karma-shared.conf.js","path":"karma-shared.conf.js","contentType":"file"},{"name":"package.json","path":"package.json","contentType":"file"},{"name":"validate-commit-msg.js","path":"validate-commit-msg.js","contentType":"file"},{"name":"validate-commit-msg.spec.js","path":"validate-commit-msg.spec.js","contentType":"file"},{"name":"watchr-docs.rb","path":"watchr-docs.rb","contentType":"file"}],"totalCount":40}},"fileTreeProcessingTime":10.148978,"foldersToFetch":[],"incompleteFileTree":false,"repo":{"id":15601880,"defaultBranch":"master","name":"angular.js","ownerLogin":"drewp","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2014-01-03T05:17:43.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/104003?v=4","public":true,"private":false,"isOrgOwned":false},"codeLineWrapEnabled":false,"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"master","listCacheKey":"v0:1617246455.4280078","canEdit":false,"refType":"branch","currentOid":"760f2fb73178e56c37397b3c5876f7dac96f0455"},"path":"validate-commit-msg.js","currentUser":null,"blob":{"rawLines":["#!/usr/bin/env node","","/**"," * Git COMMIT-MSG hook for validating commit message"," * See https://docs.google.com/document/d/1rk04jEuGfk9kYzfqCuOlPTSJw3hEDZJTBN5E5f1SALo/edit"," *"," * Installation:"," * \u003e\u003e cd \u003cangular-repo\u003e"," * \u003e\u003e ln -s ../../validate-commit-msg.js .git/hooks/commit-msg"," */","var fs = require('fs');","var util = require('util');","","","var MAX_LENGTH = 100;","var PATTERN = /^(?:fixup!\\s*)?(\\w*)(\\(([\\w\\$\\.\\-\\*/]*)\\))?\\: (.*)$/;","var IGNORED = /^WIP\\:/;","var TYPES = {"," feat: true,"," fix: true,"," docs: true,"," style: true,"," refactor: true,"," perf: true,"," test: true,"," chore: true,"," revert: true","};","","","var error = function() {"," // gitx does not display it"," // http://gitx.lighthouseapp.com/projects/17830/tickets/294-feature-display-hook-error-message-when-hook-fails"," // https://groups.google.com/group/gitx/browse_thread/thread/a03bcab60844b812"," console.error('INVALID COMMIT MSG: ' + util.format.apply(null, arguments));","};","","","var validateMessage = function(message) {"," var isValid = true;",""," if (IGNORED.test(message)) {"," console.log('Commit message validation ignored.');"," return true;"," }",""," if (message.length \u003e MAX_LENGTH) {"," error('is longer than %d characters !', MAX_LENGTH);"," isValid = false;"," }",""," var match = PATTERN.exec(message);",""," if (!match) {"," error('does not match \"\u003ctype\u003e(\u003cscope\u003e): \u003csubject\u003e\" ! was: ' + message);"," return false;"," }",""," var type = match[1];"," var scope = match[3];"," var subject = match[4];",""," if (!TYPES.hasOwnProperty(type)) {"," error('\"%s\" is not allowed type !', type);"," return false;"," }",""," // Some more ideas, do want anything like this ?"," // - allow only specific scopes (eg. fix(docs) should not be allowed ?"," // - auto correct the type to lower case ?"," // - auto correct first letter of the subject to lower case ?"," // - auto add empty line after subject ?"," // - auto remove empty () ?"," // - auto correct typos in type ?"," // - store incorrect messages, so that we can learn",""," return isValid;","};","","","var firstLineFromBuffer = function(buffer) {"," return buffer.toString().split('\\n').shift();","};","","","","// publish for testing","exports.validateMessage = validateMessage;","","// hacky start if not run by jasmine :-D","if (process.argv.join('').indexOf('jasmine-node') === -1) {"," var commitMsgFile = process.argv[2];"," var incorrectLogFile = commitMsgFile.replace('COMMIT_EDITMSG', 'logs/incorrect-commit-msgs');",""," fs.readFile(commitMsgFile, function(err, buffer) {"," var msg = firstLineFromBuffer(buffer);",""," if (!validateMessage(msg)) {"," fs.appendFile(incorrectLogFile, msg + '\\n', function() {"," process.exit(1);"," });"," } else {"," process.exit(0);"," }"," });","}"],"stylingDirectives":null,"colorizedLines":null,"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/drewp/angular.js/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null},"displayName":"validate-commit-msg.js","displayUrl":"https://github.com/drewp/angular.js/blob/master/validate-commit-msg.js?raw=true","headerInfo":{"blobSize":"2.6 KB","deleteTooltip":"You must be signed in to make or propose changes","editTooltip":"You must be signed in to make or propose changes","ghDesktopPath":"https://desktop.github.com","isGitLfs":false,"onBranch":true,"shortPath":"c68ebb7","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fdrewp%2Fangular.js%2Fblob%2Fmaster%2Fvalidate-commit-msg.js","isCSV":false,"isRichtext":false,"toc":null,"lineInfo":{"truncatedLoc":"106","truncatedSloc":"83"},"mode":"executable file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplate":null,"discussionTemplate":null,"language":"JavaScript","languageID":183,"large":false,"planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/drewp/angular.js/blob/master/validate-commit-msg.js","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","releasePath":"/drewp/angular.js/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/drewp/angular.js/raw/refs/heads/master/validate-commit-msg.js","renderImageOrRaw":false,"richText":null,"renderedFileInfo":null,"shortPath":null,"symbolsEnabled":true,"tabSize":8,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":null,"showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":{"timed_out":false,"not_analyzed":false,"symbols":[{"name":"error","kind":"function","ident_start":605,"ident_end":610,"extent_start":605,"extent_end":928,"fully_qualified_name":"error","ident_utf16":{"start":{"line_number":30,"utf16_col":4},"end":{"line_number":30,"utf16_col":9}},"extent_utf16":{"start":{"line_number":30,"utf16_col":4},"end":{"line_number":35,"utf16_col":1}}},{"name":"validateMessage","kind":"function","ident_start":936,"ident_end":951,"extent_start":936,"extent_end":1975,"fully_qualified_name":"validateMessage","ident_utf16":{"start":{"line_number":38,"utf16_col":4},"end":{"line_number":38,"utf16_col":19}},"extent_utf16":{"start":{"line_number":38,"utf16_col":4},"end":{"line_number":77,"utf16_col":1}}},{"name":"firstLineFromBuffer","kind":"function","ident_start":1983,"ident_end":2002,"extent_start":1983,"extent_end":2073,"fully_qualified_name":"firstLineFromBuffer","ident_utf16":{"start":{"line_number":80,"utf16_col":4},"end":{"line_number":80,"utf16_col":23}},"extent_utf16":{"start":{"line_number":80,"utf16_col":4},"end":{"line_number":82,"utf16_col":1}}}]}},"copilotInfo":null,"copilotAccessAllowed":false,"modelsAccessAllowed":false,"modelsRepoIntegrationEnabled":false,"csrf_tokens":{"/drewp/angular.js/branches":{"post":"3ULV2kvPycdZclQa4d2PeVC_P5qDwxuvNzZsdfvf3wMBU8PQz0yZPByL0at8WrH0rl9WfqNWJfkKNWjR8tt_Gg"},"/repos/preferences":{"post":"3ygaZNdcO-bQ10qr-J7ONuW27R0WP0R3pSxX3ZqrUm2Z1Lg55RudYO9a3w0tCZI_-wEU3ZC5lmAldtlNXMf0cg"}}},"title":"angular.js/validate-commit-msg.js at master · drewp/angular.js","appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-263cab1760dd.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-1b17b3e7786a.js","githubDevUrl":null,"enabled_features":{"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true}}}
0