@firestartr/cli 1.29.2 → 1.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55451,6 +55451,7 @@ const user_1 = __importDefault(__nccwpck_require__(2851));
55451
55451
  const pull_request_1 = __importDefault(__nccwpck_require__(4670));
55452
55452
  const auth_1 = __importDefault(__nccwpck_require__(7745));
55453
55453
  const issues_1 = __importDefault(__nccwpck_require__(5934));
55454
+ const branches_1 = __importDefault(__nccwpck_require__(6954));
55454
55455
  const auth_2 = __nccwpck_require__(7745);
55455
55456
  exports["default"] = {
55456
55457
  org: organization_1.default,
@@ -55463,6 +55464,7 @@ exports["default"] = {
55463
55464
  auth: auth_1.default,
55464
55465
  pulls: pull_request_1.default,
55465
55466
  issues: issues_1.default,
55467
+ branches: branches_1.default,
55466
55468
  };
55467
55469
 
55468
55470
 
@@ -55532,6 +55534,86 @@ exports.getOctokitForOrg = getOctokitForOrg;
55532
55534
  exports["default"] = { getOctokitForOrg };
55533
55535
 
55534
55536
 
55537
+ /***/ }),
55538
+
55539
+ /***/ 6954:
55540
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
55541
+
55542
+ "use strict";
55543
+
55544
+ var __importDefault = (this && this.__importDefault) || function (mod) {
55545
+ return (mod && mod.__esModule) ? mod : { "default": mod };
55546
+ };
55547
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
55548
+ exports.createOrphanBranch = exports.createBranch = exports.getBranch = exports.listBranches = void 0;
55549
+ const auth_1 = __nccwpck_require__(7745);
55550
+ const debug_1 = __importDefault(__nccwpck_require__(7984));
55551
+ const messageLog = (0, debug_1.default)('firestartr:github:branches');
55552
+ const SHA1_EMPTY_TREE = '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
55553
+ async function listBranches(repo, owner = 'prefapp') {
55554
+ messageLog(`Getting branches for ${owner}/${repo}`);
55555
+ const octokit = await (0, auth_1.getOctokitForOrg)(owner);
55556
+ const response = await octokit.rest.repos.listBranches({
55557
+ owner,
55558
+ repo,
55559
+ per_page: 100,
55560
+ page: 0,
55561
+ });
55562
+ return response.data;
55563
+ }
55564
+ exports.listBranches = listBranches;
55565
+ async function getBranch(repo, branch, owner = 'prefapp') {
55566
+ messageLog(`Getting branch ${branch} for ${owner}/${repo}`);
55567
+ const octokit = await (0, auth_1.getOctokitForOrg)(owner);
55568
+ const response = await octokit.rest.repos.getBranch({
55569
+ owner,
55570
+ repo,
55571
+ branch,
55572
+ });
55573
+ return response.data;
55574
+ }
55575
+ exports.getBranch = getBranch;
55576
+ async function createBranch(repo, branch, sha, owner = 'prefapp') {
55577
+ messageLog(`Creating branch ${branch} for ${owner}/${repo}`);
55578
+ const octokit = await (0, auth_1.getOctokitForOrg)(owner);
55579
+ const response = await octokit.rest.git.createRef({
55580
+ owner,
55581
+ repo,
55582
+ ref: `refs/heads/${branch}`,
55583
+ sha,
55584
+ });
55585
+ return response.data;
55586
+ }
55587
+ exports.createBranch = createBranch;
55588
+ async function createOrphanBranch(repo, branch, owner = 'prefapp') {
55589
+ messageLog(`Creating orphan branch ${branch} for ${owner}/${repo}`);
55590
+ const octokit = await (0, auth_1.getOctokitForOrg)(owner);
55591
+ // Create a commit with an empty tree
55592
+ const { data: commit } = await octokit.request('POST /repos/{owner}/{repo}/git/commits', {
55593
+ owner,
55594
+ repo,
55595
+ message: `Inicializando rama huérfana ${branch}`,
55596
+ tree: SHA1_EMPTY_TREE,
55597
+ parents: [],
55598
+ });
55599
+ // Create a reference to the commit
55600
+ const response = await octokit.request('POST /repos/{owner}/{repo}/git/refs', {
55601
+ owner,
55602
+ repo,
55603
+ ref: `refs/heads/${branch}`,
55604
+ sha: commit.sha,
55605
+ });
55606
+ return response.data;
55607
+ }
55608
+ exports.createOrphanBranch = createOrphanBranch;
55609
+ exports["default"] = {
55610
+ listBranches,
55611
+ getBranch,
55612
+ createBranch,
55613
+ createOrphanBranch,
55614
+ };
55615
+
55616
+
55535
55617
  /***/ }),
55536
55618
 
55537
55619
  /***/ 5934: