New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jira-precommit-hook

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jira-precommit-hook - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

2

lib/issue-strategies/bug-maintenance.js

@@ -15,3 +15,3 @@ 'use strict';

if (issue === null || issue.fields.status.statusCategory.colorName !== 'yellow') {
return _Promise.reject(new Error('Cannot commit against this issue ' + issue.key));
return _Promise.reject(new Error('Cannot commit against this issue ' + issue.key + '. Make sure the issue exists and has a yellow status'));
}

@@ -18,0 +18,0 @@

@@ -9,2 +9,4 @@ 'use strict';

var _interopRequireDefault = require('babel-runtime/helpers/interop-require-default')['default'];
_Object$defineProperty(exports, '__esModule', {

@@ -20,2 +22,6 @@ value: true

var _lodash = require('lodash');
var _lodash2 = _interopRequireDefault(_lodash);
function promisify(func) {

@@ -47,3 +53,3 @@ return function () {

if (typeof currentProperty === 'function') {
_jira.JiraApi.prototype[key] = promisify(currentProperty);
_jira.JiraApi.prototype[key] = _lodash2['default'].memoize(promisify(currentProperty));
}

@@ -50,0 +56,0 @@ });

@@ -14,5 +14,3 @@ 'use strict';

exports.findProjectKey = findProjectKey;
exports.getEpicLinkField = getEpicLinkField;
exports.findIssueLinkParentKey = findIssueLinkParentKey;
exports.findParent = findParent;

@@ -31,14 +29,17 @@ var _lodash = require('lodash');

function getEpicLinkField(jiraClient) {
var getEpicLinkField = _lodash2['default'].memoize(function (jiraClient) {
return jiraClient.listFields().then(function (fields) {
for (var i = 0; i < fields.length; i++) {
if (fields[i].name === 'Epic Link') {
return fields[i].id;
return _Promise.resolve(fields[i].id);
}
}
return _Promise.reject('Cannot find Epic Link Field ID. Should defined in field URI.');
return _Promise.reject('Cannot find Epic Link Field.');
});
}
}, function (jiraClient) {
return jiraClient.host;
});
exports.getEpicLinkField = getEpicLinkField;
function findIssueLinkParentKey(issue) {

@@ -66,3 +67,3 @@ var result = null;

function findParent(issue, jiraClient) {
var findParent = _lodash2['default'].memoize(function (issue, jiraClient) {
switch (issue.fields.issuetype.name) {

@@ -94,2 +95,5 @@ case 'Sub-task':

}
}
}, function (issue) {
return JSON.stringify(issue);
});
exports.findParent = findParent;

@@ -54,3 +54,3 @@ /* eslint no-process-exit:0 */

function getCommitMsg(path) {
function getCommitMsg(readPromise) {
var jiraAPI = undefined,

@@ -69,3 +69,3 @@ jiraConfigPath = undefined;

return (0, _jiraOperations.findProjectKey)(jiraAPI);
}), _fsPromise2['default'].readFile(path, { encoding: 'utf8' })]).then(function (_ref) {
}), readPromise]).then(function (_ref) {
var _ref2 = _slicedToArray(_ref, 2);

@@ -76,2 +76,8 @@

var firstWord = fileContents.split(' ')[0];
if (firstWord === 'Merge' || firstWord === 'Revert') {
return null;
}
var issues = getIssueReference(fileContents, projectKey);

@@ -83,14 +89,25 @@ return issueHandler.issueStrategizer(issues, jiraAPI);

function precommit(path) {
return getCommitMsg(path).then(function () {
var readPromise = _fsPromise2['default'].readFile(path, { encoding: 'utf8' });
return getCommitMsg(readPromise).then(function () {
return 0;
})['catch'](function (err) {
if (typeof err === 'string') {
console.error(err.red);
} else if (process.env.NODE_ENV === 'development') {
console.error(err.stack.red);
} else {
console.error(err.toString().red);
}
return 1;
return readPromise.then(function (contents) {
console.log('Commit Message:');
console.log(contents);
if (typeof err === 'string') {
console.error(err.red);
} else if (process.env.NODE_ENV === 'development') {
console.error(err.stack.red);
} else {
console.error(err.toString().red);
}
return 1;
})['catch'](function (err2) {
console.log('Failed to read commit message file.'.red);
return 1;
});
});
}
{
"name": "jira-precommit-hook",
"version": "0.1.0",
"version": "0.2.0",
"description": "Git commit hook to verify commit messages are tagged with a JIRA issue number",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -39,1 +39,19 @@ jira-precommit-hook

```
**SYMLINK DIRECTORY NOTICE**
If the hooks directory in your .git folder is symlinked, the module will be unable to find it. To avoid this, do not symlink your hooks folder inside of your project's git directory.
# Making JIRA Commits
_In order to make a successful commit with the precommit hook, **ALL** issues being committed must meet the following requirements:_
- There must be at least one issue in the commit message
- All committed issues must exist in the project designated in the .jirarc
_At **least one** issue being committed must meet the following requirements:_
- The issue must be open for commits
- The parents of the issue must also be open for commits
- The issue must lead up to an initiative
- The issue must not be an initiative, epic, nor a deployment task
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc