Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

git3po

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

git3po - npm Package Compare versions

Comparing version 1.5.0 to 1.6.0

30

dist/action.js
'use strict';
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const _ = require('lodash');
const preprocess = require('./filter').preprocess;

@@ -16,3 +23,4 @@ class Action {

CLOSE: 'close',
LOCK: 'lock'
LOCK: 'lock',
MERGE: 'merge'
};

@@ -30,15 +38,25 @@ }

apply(issue, github) {
let action = (0, _extends3.default)({}, this._action);
switch (this._action.type) {
case Action.TYPES.ADD_COMMENT:
return github.addComment(issue, this._action.body);
return github.addComment(issue, action.body);
case Action.TYPES.ADD_LABEL:
return github.addLabel(issue, this._action.label);
return github.addLabel(issue, action.label);
case Action.TYPES.REMOVE_LABEL:
return github.removeLabel(issue, this._action.label);
return github.removeLabel(issue, action.label);
case Action.TYPES.CLOSE:
return github.closeIssue(issue);
case Action.TYPES.LOCK:
return github.lockIssue(issue, this._action.reason);
return github.lockobject(issue, action.reason);
case Action.TYPES.MERGE:
// For now, only preprocess this action. Doing the same for the others is probably fine,
// but hasn't been tested.
// By default, use the PR's title as the commit title.
if (!('title' in action)) {
action.title = '%%title%%';
}
action = preprocess(action, issue);
return github.mergePullRequest(issue, action.mergeMethod, action.title, action.message);
default:
throw new TypeError(`Unknown action type: ${this._action.type}`);
throw new TypeError(`Unknown action type: ${action.type}`);
}

@@ -45,0 +63,0 @@ }

1

dist/filter.js

@@ -90,2 +90,3 @@ 'use strict';

author: issue.user && issue.user.login,
title: issue.title,
date: relativeTimePhrase => chrono.parseDate(relativeTimePhrase)

@@ -92,0 +93,0 @@ };

@@ -84,5 +84,6 @@ 'use strict';

return Promise.map(page, (() => {
var _ref = (0, _asyncToGenerator3.default)(function* (pr) {
const index = page.indexOf(pr);
const issue = yield _this2.fetchIssue(pr);
var _ref = (0, _asyncToGenerator3.default)(function* (prItem) {
const index = page.indexOf(prItem);
const pr = yield _this2.fetchPullRequest(prItem.number);
const issue = yield _this2.fetchIssue(prItem.number);
page[index] = (0, _assign2.default)({}, issue, pr);

@@ -98,8 +99,8 @@ });

fetchIssue(pullRequest) {
fetchPullRequest(number) {
var _this3 = this;
return (0, _asyncToGenerator3.default)(function* () {
const url = `${_this3.url}/issues/${pullRequest.number}`;
log(`fetching issue for PR=${pullRequest.number}`);
const url = `${_this3.url}/pulls/${number}`;
log(`fetching pr #${number}`);
const response = yield _this3._authenticatedRequest(url).promise();

@@ -110,14 +111,25 @@ return response.body;

fetchComments(issue) {
fetchIssue(number) {
var _this4 = this;
return (0, _asyncToGenerator3.default)(function* () {
const url = `${_this4.url}/issues/${issue.number}/comments`;
log(`fetching comments for issue=${issue.number}`);
const url = `${_this4.url}/issues/${number}`;
log(`fetching issue #${number}`);
const response = yield _this4._authenticatedRequest(url).promise();
return response.body;
})();
}
fetchComments(issue) {
var _this5 = this;
return (0, _asyncToGenerator3.default)(function* () {
const url = `${_this5.url}/issues/${issue.number}/comments`;
log(`fetching comments for issue=${issue.number}`);
const response = yield _this5._authenticatedRequest(url).promise();
if (issue.pull_request) {
log(`fetching comments for PR=${issue.number}`);
const reviewCommentsUrl = url.replace('/issues/', '/pulls/');
const reviewResponse = yield _this4._authenticatedRequest(reviewCommentsUrl).promise();
const reviewResponse = yield _this5._authenticatedRequest(reviewCommentsUrl).promise();
return response.body.concat(reviewResponse.body);

@@ -131,8 +143,8 @@ } else {

fetchCommits(pullRequest) {
var _this5 = this;
var _this6 = this;
return (0, _asyncToGenerator3.default)(function* () {
const url = `${_this5.url}/pulls/${pullRequest.number}/commits`;
const url = `${_this6.url}/pulls/${pullRequest.number}/commits`;
log(`fetching commits for PR=${pullRequest.number}`);
const response = yield _this5._authenticatedRequest(url).promise();
const response = yield _this6._authenticatedRequest(url).promise();
return response.body;

@@ -143,6 +155,6 @@ })();

dryRunGuardedRequest(url, method, action) {
var _this6 = this;
var _this7 = this;
return (0, _asyncToGenerator3.default)(function* () {
if (_this6._dryRun) {
if (_this7._dryRun) {
log(`dry run, skipping ${method.toUpperCase()} request to ${url}`);

@@ -152,3 +164,3 @@ return Promise.resolve();

let promiseLike = action(_this6._authenticatedRequest(`${_this6.url}${url}`, method));
let promiseLike = action(_this7._authenticatedRequest(`${_this7.url}${url}`, method));
if (typeof promiseLike.promise === 'function') {

@@ -194,2 +206,15 @@ promiseLike = promiseLike.promise();

mergePullRequest(pr, mergeMethod, title, message) {
return this.dryRunGuardedRequest(`/pulls/${pr.number}/merge`, 'put',
/* eslint-disable camelcase */
request => request.type('json').send({
sha: pr.head.sha,
merge_method: mergeMethod || 'rebase',
commit_title: title,
commit_message: message
})
/* eslint-enable camelcase */
);
}
static transformIssue(issue) {

@@ -203,2 +228,4 @@ return {

author: issue.user && issue.user.login,
mergeable: issue.mergeable,
mergeableState: issue.mergeable_state,
labels: (issue.labels || []).map(label => label.name),

@@ -205,0 +232,0 @@ updatedAt: new Date(issue.updated_at)

const _ = require('lodash')
const preprocess = require('./filter').preprocess

@@ -15,2 +16,3 @@ class Action {

LOCK: 'lock',
MERGE: 'merge',
}

@@ -28,15 +30,25 @@ }

apply(issue, github) {
let action = {...this._action}
switch (this._action.type) {
case Action.TYPES.ADD_COMMENT:
return github.addComment(issue, this._action.body)
return github.addComment(issue, action.body)
case Action.TYPES.ADD_LABEL:
return github.addLabel(issue, this._action.label)
return github.addLabel(issue, action.label)
case Action.TYPES.REMOVE_LABEL:
return github.removeLabel(issue, this._action.label)
return github.removeLabel(issue, action.label)
case Action.TYPES.CLOSE:
return github.closeIssue(issue)
case Action.TYPES.LOCK:
return github.lockIssue(issue, this._action.reason)
return github.lockobject(issue, action.reason)
case Action.TYPES.MERGE:
// For now, only preprocess this action. Doing the same for the others is probably fine,
// but hasn't been tested.
// By default, use the PR's title as the commit title.
if (!('title' in action)) {
action.title = '%%title%%'
}
action = preprocess(action, issue)
return github.mergePullRequest(issue, action.mergeMethod, action.title, action.message)
default:
throw new TypeError(`Unknown action type: ${this._action.type}`)
throw new TypeError(`Unknown action type: ${action.type}`)
}

@@ -43,0 +55,0 @@ }

@@ -82,2 +82,3 @@ const _ = require('lodash')

author: issue.user && issue.user.login,
title: issue.title,
date: relativeTimePhrase => chrono.parseDate(relativeTimePhrase),

@@ -84,0 +85,0 @@ }

@@ -65,5 +65,6 @@ const log = require('debug')('git3po:github')

return this._fetchUntilFinished(query, page => {
return Promise.map(page, async pr => {
const index = page.indexOf(pr)
const issue = await this.fetchIssue(pr)
return Promise.map(page, async prItem => {
const index = page.indexOf(prItem)
const pr = await this.fetchPullRequest(prItem.number)
const issue = await this.fetchIssue(prItem.number)
page[index] = Object.assign({}, issue, pr)

@@ -74,5 +75,5 @@ })

async fetchIssue(pullRequest) {
const url = `${this.url}/issues/${pullRequest.number}`
log(`fetching issue for PR=${pullRequest.number}`)
async fetchPullRequest(number) {
const url = `${this.url}/pulls/${number}`
log(`fetching pr #${number}`)
const response = await this._authenticatedRequest(url).promise()

@@ -82,2 +83,9 @@ return response.body

async fetchIssue(number) {
const url = `${this.url}/issues/${number}`
log(`fetching issue #${number}`)
const response = await this._authenticatedRequest(url).promise()
return response.body
}
async fetchComments(issue) {

@@ -172,2 +180,17 @@ const url = `${this.url}/issues/${issue.number}/comments`

mergePullRequest(pr, mergeMethod, title, message) {
return this.dryRunGuardedRequest(
`/pulls/${pr.number}/merge`,
'put',
/* eslint-disable camelcase */
request => request.type('json').send({
sha: pr.head.sha,
merge_method: mergeMethod || 'rebase',
commit_title: title,
commit_message: message,
})
/* eslint-enable camelcase */
)
}
static transformIssue(issue) {

@@ -181,2 +204,4 @@ return {

author: issue.user && issue.user.login,
mergeable: issue.mergeable,
mergeableState: issue.mergeable_state,
labels: (issue.labels || []).map(label => label.name),

@@ -183,0 +208,0 @@ updatedAt: new Date(issue.updated_at),

{
"name": "git3po",
"version": "1.5.0",
"version": "1.6.0",
"description": "The best git3po around.",

@@ -5,0 +5,0 @@ "main": "./dist/core.js",

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