github-cherry-pick
Advanced tools
Comparing version 0.1.14 to 0.1.15
255
lib/index.js
@@ -6,11 +6,8 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
var _git = require("shared-github-internals/lib/git"); | ||
var _debug = require("debug"); | ||
var _debug = _interopRequireDefault(require("debug")); | ||
var _debug2 = _interopRequireDefault(_debug); | ||
var _package = require("../package"); | ||
@@ -20,5 +17,9 @@ | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } // strict | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
const createCommit = (() => { | ||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
const createCommit = | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref = _asyncToGenerator(function* ({ | ||
@@ -34,3 +35,7 @@ author, | ||
}) { | ||
var _ref2 = yield octokit.gitdata.createCommit({ | ||
const { | ||
data: { | ||
sha | ||
} | ||
} = yield octokit.gitdata.createCommit({ | ||
author, | ||
@@ -46,5 +51,2 @@ committer, | ||
}); | ||
const sha = _ref2.data.sha; | ||
return sha; | ||
@@ -56,7 +58,23 @@ }); | ||
}; | ||
})(); | ||
}(); | ||
const merge = (() => { | ||
var _ref3 = _asyncToGenerator(function* ({ base, commit, octokit, owner, repo }) { | ||
var _ref4 = yield octokit.repos.merge({ | ||
const merge = | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref2 = _asyncToGenerator(function* ({ | ||
base, | ||
commit, | ||
octokit, | ||
owner, | ||
repo | ||
}) { | ||
const { | ||
data: { | ||
commit: { | ||
tree: { | ||
sha: tree | ||
} | ||
} | ||
} | ||
} = yield octokit.repos.merge({ | ||
base, | ||
@@ -67,5 +85,2 @@ head: commit, | ||
}); | ||
const tree = _ref4.data.commit.tree.sha; | ||
return tree; | ||
@@ -75,35 +90,53 @@ }); | ||
return function merge(_x2) { | ||
return _ref3.apply(this, arguments); | ||
return _ref2.apply(this, arguments); | ||
}; | ||
})(); | ||
}(); | ||
const retrieveCommitDetails = (() => { | ||
var _ref5 = _asyncToGenerator(function* ({ commit, octokit, owner, repo }) { | ||
var _ref6 = yield octokit.gitdata.getCommit({ | ||
const retrieveCommitDetails = | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref3 = _asyncToGenerator(function* ({ | ||
commit, | ||
octokit, | ||
owner, | ||
repo | ||
}) { | ||
const { | ||
data: { | ||
author, | ||
committer, | ||
message, | ||
parents: [{ | ||
sha: parent | ||
}] | ||
} | ||
} = yield octokit.gitdata.getCommit({ | ||
commit_sha: commit, | ||
owner, | ||
repo | ||
}), | ||
_ref6$data = _ref6.data; | ||
const author = _ref6$data.author, | ||
committer = _ref6$data.committer, | ||
message = _ref6$data.message; | ||
var _ref6$data$parents = _slicedToArray(_ref6$data.parents, 1); | ||
const parent = _ref6$data$parents[0].sha; | ||
return { author, committer, message, parent }; | ||
}); | ||
return { | ||
author, | ||
committer, | ||
message, | ||
parent | ||
}; | ||
}); | ||
return function retrieveCommitDetails(_x3) { | ||
return _ref5.apply(this, arguments); | ||
return _ref3.apply(this, arguments); | ||
}; | ||
})(); | ||
}(); | ||
const createSiblingCommit = (() => { | ||
var _ref7 = _asyncToGenerator(function* ({ | ||
const createSiblingCommit = | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref4 = _asyncToGenerator(function* ({ | ||
commit, | ||
head: { author, committer, ref, tree }, | ||
head: { | ||
author, | ||
committer, | ||
ref, | ||
tree | ||
}, | ||
octokit, | ||
@@ -135,11 +168,17 @@ owner, | ||
return function createSiblingCommit(_x4) { | ||
return _ref7.apply(this, arguments); | ||
return _ref4.apply(this, arguments); | ||
}; | ||
})(); | ||
}(); | ||
const cherryPickCommit = (() => { | ||
var _ref8 = _asyncToGenerator(function* ({ | ||
const cherryPickCommit = | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref5 = _asyncToGenerator(function* ({ | ||
commit, | ||
debug, | ||
head: { ref, sha, tree }, | ||
head: { | ||
ref, | ||
sha, | ||
tree | ||
}, | ||
octokit, | ||
@@ -149,3 +188,8 @@ owner, | ||
}) { | ||
var _ref9 = yield retrieveCommitDetails({ | ||
const { | ||
author, | ||
committer, | ||
message, | ||
parent | ||
} = yield retrieveCommitDetails({ | ||
commit, | ||
@@ -156,12 +200,11 @@ octokit, | ||
}); | ||
const author = _ref9.author, | ||
committer = _ref9.committer, | ||
message = _ref9.message, | ||
parent = _ref9.parent; | ||
debug("creating sibling commit"); | ||
yield createSiblingCommit({ | ||
commit, | ||
head: { author, committer, ref, tree }, | ||
head: { | ||
author, | ||
committer, | ||
ref, | ||
tree | ||
}, | ||
octokit, | ||
@@ -209,8 +252,10 @@ owner, | ||
return function cherryPickCommit(_x5) { | ||
return _ref8.apply(this, arguments); | ||
return _ref5.apply(this, arguments); | ||
}; | ||
})(); | ||
}(); | ||
const cherryPickCommitsOnReference = (() => { | ||
var _ref10 = _asyncToGenerator(function* ({ | ||
const cherryPickCommitsOnReference = | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref6 = _asyncToGenerator(function* ({ | ||
commits, | ||
@@ -224,3 +269,9 @@ debug, | ||
}) { | ||
var _ref11 = yield octokit.gitdata.getCommit({ | ||
const { | ||
data: { | ||
tree: { | ||
sha: initialHeadTree | ||
} | ||
} | ||
} = yield octokit.gitdata.getCommit({ | ||
commit_sha: initialHeadSha, | ||
@@ -230,17 +281,25 @@ owner, | ||
}); | ||
const initialHeadTree = _ref11.data.tree.sha; | ||
var _ref12 = yield commits.reduce((() => { | ||
var _ref13 = _asyncToGenerator(function* (previousCherryPick, commit) { | ||
var _ref14 = yield previousCherryPick; | ||
const sha = _ref14.sha, | ||
tree = _ref14.tree; | ||
debug("cherry-picking", { commit, ref, sha }); | ||
const { | ||
sha: newHeadSha | ||
} = yield commits.reduce( | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref7 = _asyncToGenerator(function* (previousCherryPick, commit) { | ||
const { | ||
sha, | ||
tree | ||
} = yield previousCherryPick; | ||
debug("cherry-picking", { | ||
commit, | ||
ref, | ||
sha | ||
}); | ||
return cherryPickCommit({ | ||
commit, | ||
debug, | ||
head: { ref, sha, tree }, | ||
head: { | ||
ref, | ||
sha, | ||
tree | ||
}, | ||
octokit, | ||
@@ -253,12 +312,8 @@ owner, | ||
return function (_x7, _x8) { | ||
return _ref13.apply(this, arguments); | ||
return _ref7.apply(this, arguments); | ||
}; | ||
})(), Promise.resolve({ | ||
}(), Promise.resolve({ | ||
sha: initialHeadSha, | ||
tree: initialHeadTree | ||
})); | ||
const newHeadSha = _ref12.sha; | ||
return newHeadSha; | ||
@@ -268,13 +323,13 @@ }); | ||
return function cherryPickCommitsOnReference(_x6) { | ||
return _ref10.apply(this, arguments); | ||
return _ref6.apply(this, arguments); | ||
}; | ||
})(); | ||
}(); // eslint-disable-next-line max-lines-per-function | ||
// eslint-disable-next-line max-lines-per-function | ||
const cherryPickCommits = (() => { | ||
var _ref15 = _asyncToGenerator(function* ({ | ||
const cherryPickCommits = | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref8 = _asyncToGenerator(function* ({ | ||
// Should only be used in tests. | ||
_intercept = function () { | ||
return Promise.resolve(); | ||
}, | ||
_intercept = () => Promise.resolve(), | ||
commits, | ||
@@ -286,4 +341,9 @@ head, | ||
}) { | ||
const debug = (0, _debug2.default)(_package.name); | ||
debug("starting", { commits, head, owner, repo }); | ||
const debug = (0, _debug.default)(_package.name); | ||
debug("starting", { | ||
commits, | ||
head, | ||
owner, | ||
repo | ||
}); | ||
const initialHeadSha = yield (0, _git.fetchReferenceSha)({ | ||
@@ -295,7 +355,11 @@ octokit, | ||
}); | ||
yield _intercept({ initialHeadSha }); | ||
yield _intercept({ | ||
initialHeadSha | ||
}); | ||
return (0, _git.withTemporaryReference)({ | ||
action: (() => { | ||
var _ref16 = _asyncToGenerator(function* (temporaryRef) { | ||
debug({ temporaryRef }); | ||
action: function () { | ||
var _ref9 = _asyncToGenerator(function* (temporaryRef) { | ||
debug({ | ||
temporaryRef | ||
}); | ||
const newSha = yield cherryPickCommitsOnReference({ | ||
@@ -325,5 +389,5 @@ commits, | ||
return function action(_x10) { | ||
return _ref16.apply(this, arguments); | ||
return _ref9.apply(this, arguments); | ||
}; | ||
})(), | ||
}(), | ||
octokit, | ||
@@ -338,6 +402,7 @@ owner, | ||
return function cherryPickCommits(_x9) { | ||
return _ref15.apply(this, arguments); | ||
return _ref8.apply(this, arguments); | ||
}; | ||
})(); | ||
}(); | ||
exports.default = cherryPickCommits; | ||
var _default = cherryPickCommits; | ||
exports.default = _default; |
{ | ||
"author": "Thibault Derousseaux <tibdex@gmail.com>", | ||
"dependencies": { | ||
"debug": "^3.1.0", | ||
"shared-github-internals": "^0.1.4" | ||
"debug": "^4.0.1", | ||
"shared-github-internals": "^0.1.5" | ||
}, | ||
"description": "Cherry-pick several commits on a branch using the low level Git Data operations provided by the GitHub REST API", | ||
"devDependencies": { | ||
"babel-cli": "^6.26.0", | ||
"babel-core": "^6.26.3", | ||
"babel-eslint": "^8.2.6", | ||
"babel-jest": "^23.4.2", | ||
"babel-preset-env": "^1.7.0", | ||
"babel-preset-flow": "^6.23.0", | ||
"eslint": "^5.3.0", | ||
"eslint-config-prettier": "^2.9.0", | ||
"eslint-plugin-flowtype": "^2.50.0", | ||
"eslint-plugin-import": "^2.13.0", | ||
"@babel/cli": "^7.1.0", | ||
"@babel/core": "^7.1.0", | ||
"@babel/preset-env": "^7.1.0", | ||
"@babel/preset-flow": "^7.0.0", | ||
"babel-core": "^7.0.0-bridge", | ||
"babel-eslint": "^9.0.0", | ||
"babel-jest": "^23.6.0", | ||
"eslint": "^5.6.0", | ||
"eslint-config-prettier": "^3.0.1", | ||
"eslint-plugin-flowtype": "^2.50.1", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-security": "^1.4.0", | ||
"eslint-plugin-unicorn": "^5.0.0", | ||
"flow-bin": "^0.78.0", | ||
"eslint-plugin-unicorn": "^6.0.1", | ||
"flow-bin": "^0.81.0", | ||
"flow-copy-source": "^2.0.2", | ||
"flow-typed": "^2.4.0", | ||
"jest": "^23.4.2", | ||
"flow-typed": "^2.5.1", | ||
"jest": "^23.6.0", | ||
"jest-junit": "^5.1.0", | ||
"prettier": "^1.14.2" | ||
"prettier": "^1.14.3" | ||
}, | ||
@@ -54,3 +55,3 @@ "engines": { | ||
}, | ||
"version": "0.1.14" | ||
"version": "0.1.15" | ||
} |
@@ -13,3 +13,4 @@ [![npm version](https://img.shields.io/npm/v/github-cherry-pick.svg)](https://npmjs.org/package/github-cherry-pick) | ||
```javascript | ||
const cherryPickCommits = require("github-cherry-pick"); | ||
import cherryPickCommits from "github-cherry-pick"; | ||
// const {default: cherryPickCommits} = require("github-cherry-pick"); | ||
@@ -16,0 +17,0 @@ cherryPickCommits({ |
364
195
21602
19
+ Addeddebug@4.3.4(transitive)
+ Addedms@2.1.2(transitive)
- Removedms@2.1.3(transitive)
Updateddebug@^4.0.1