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

Skip to content
{"payload":{"allShortcutsEnabled":false,"fileTree":{"":{"items":[{"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":"src","path":"src","contentType":"directory"},{"name":"test","path":"test","contentType":"directory"},{"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":"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":"changelog.tmp.md","path":"changelog.tmp.md","contentType":"file"},{"name":"check-size.sh","path":"check-size.sh","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":"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":"package.json","path":"package.json","contentType":"file"},{"name":"release-commit.sh","path":"release-commit.sh","contentType":"file"},{"name":"start-iteration.sh","path":"start-iteration.sh","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":36}},"fileTreeProcessingTime":2.477435,"foldersToFetch":[],"incompleteFileTree":false,"repo":{"id":10851786,"defaultBranch":"master","name":"angular.js","ownerLogin":"jotbe","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2013-06-21T20:30:53.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/157015?v=4","public":true,"private":false,"isOrgOwned":false},"codeLineWrapEnabled":false,"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"master","listCacheKey":"v0:1625355956.257714","canEdit":false,"refType":"branch","currentOid":"99e85fc9b5b71a1bf3e54126b9c080b3c355c336"},"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 = 70;","var PATTERN = /^(?:fixup!\\s*)?(\\w*)(\\(([\\w\\$\\.\\-\\*/]*)\\))?\\: (.*)$/;","var IGNORED = /^WIP\\:/;","var TYPES = {"," feat: true,"," fix: true,"," docs: true,"," style: true,"," refactor: 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":"/jotbe/angular.js/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null},"displayName":"validate-commit-msg.js","displayUrl":"https://github.com/jotbe/angular.js/blob/master/validate-commit-msg.js?raw=true","headerInfo":{"blobSize":"2.58 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":"665135a","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fjotbe%2Fangular.js%2Fblob%2Fmaster%2Fvalidate-commit-msg.js","isCSV":false,"isRichtext":false,"toc":null,"lineInfo":{"truncatedLoc":"105","truncatedSloc":"82"},"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":"/jotbe/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":"/jotbe/angular.js/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/jotbe/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":584,"ident_end":589,"extent_start":584,"extent_end":907,"fully_qualified_name":"error","ident_utf16":{"start":{"line_number":29,"utf16_col":4},"end":{"line_number":29,"utf16_col":9}},"extent_utf16":{"start":{"line_number":29,"utf16_col":4},"end":{"line_number":34,"utf16_col":1}}},{"name":"validateMessage","kind":"function","ident_start":915,"ident_end":930,"extent_start":915,"extent_end":1954,"fully_qualified_name":"validateMessage","ident_utf16":{"start":{"line_number":37,"utf16_col":4},"end":{"line_number":37,"utf16_col":19}},"extent_utf16":{"start":{"line_number":37,"utf16_col":4},"end":{"line_number":76,"utf16_col":1}}},{"name":"firstLineFromBuffer","kind":"function","ident_start":1962,"ident_end":1981,"extent_start":1962,"extent_end":2052,"fully_qualified_name":"firstLineFromBuffer","ident_utf16":{"start":{"line_number":79,"utf16_col":4},"end":{"line_number":79,"utf16_col":23}},"extent_utf16":{"start":{"line_number":79,"utf16_col":4},"end":{"line_number":81,"utf16_col":1}}}]}},"copilotInfo":null,"copilotAccessAllowed":false,"modelsAccessAllowed":false,"modelsRepoIntegrationEnabled":false,"csrf_tokens":{"/jotbe/angular.js/branches":{"post":"qMgK66ARcrR1TgdHTfHgSzMO0PLAAkvxZNie5qizl1omF1Qh35r-95mPZ91BC2NT-aZ8pbiTYSBHkFWH58r8NA"},"/repos/preferences":{"post":"AhkvDM7tmVJEbo6JIK4D870m0OOPgSJ956SZDGgV4VNclXwROU60B7D2vI_MB1tVyKrwadAI6rzs2VDK98jLlw"}}},"title":"angular.js/validate-commit-msg.js at master · jotbe/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