@evanpurkhiser/tooling-personal 1.11.0 → 1.15.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.
package/dist/cmd/pr.js CHANGED
@@ -6,13 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const chalk_1 = __importDefault(require("chalk"));
7
7
  const listr2_1 = require("listr2");
8
8
  const open_1 = __importDefault(require("open"));
9
+ const simple_git_1 = __importDefault(require("simple-git"));
9
10
  const assignees_1 = require("../assignees");
10
11
  const editor_1 = require("../editor");
11
12
  const fzf_1 = require("../fzf");
12
- const git_1 = __importDefault(require("../git"));
13
13
  const pulls_1 = require("../pulls");
14
14
  const utils_1 = require("../utils");
15
- const getCommits = () => git_1.default.log({ from: 'HEAD', to: 'origin/master' });
15
+ const getCommits = () => simple_git_1.default().log({ from: 'HEAD', to: 'origin/master' });
16
16
  async function pr() {
17
17
  const repo = await utils_1.getRepoKey();
18
18
  const rendererOptions = { showTimer: true };
@@ -71,7 +71,10 @@ async function pr() {
71
71
  // the end of the list.
72
72
  const rebaseContents = [
73
73
  ...selectedShas,
74
- ...commits.all.filter(c => !selectedShas.includes(c.hash)).map(c => c.hash),
74
+ ...commits.all
75
+ .filter(c => !selectedShas.includes(c.hash))
76
+ .map(c => c.hash)
77
+ .reverse(),
75
78
  ]
76
79
  .map(sha => `pick ${sha}`)
77
80
  .join('\n');
@@ -80,8 +83,8 @@ async function pr() {
80
83
  const willOpenPr = prs.some(pr => pr.headRefName === branchName);
81
84
  // 03. Rebase and push the selected commits
82
85
  const doRebase = async () => {
83
- await git_1.default
84
- .env('GIT_SEQUENCE_EDITOR', `echo "${rebaseContents}" >`)
86
+ await simple_git_1.default()
87
+ .env({ ...process.env, GIT_SEQUENCE_EDITOR: `echo "${rebaseContents}" >` })
85
88
  .rebase(['--interactive', '--autostash', 'origin/master']);
86
89
  };
87
90
  const doPush = async () => {
@@ -89,7 +92,7 @@ async function pr() {
89
92
  const commitIdx = newCommits.all.length - selectedCommits.length;
90
93
  const rebaseTargetCommit = newCommits.all[commitIdx];
91
94
  const refSpec = `${rebaseTargetCommit.hash}:refs/heads/${branchName}`;
92
- await git_1.default.push(['--force', 'origin', refSpec]);
95
+ await simple_git_1.default().push(['--force', 'origin', refSpec]);
93
96
  };
94
97
  const rebaseAndPushTask = new listr2_1.Listr([], { rendererOptions });
95
98
  rebaseAndPushTask.add({ title: 'Rebasing commits', task: doRebase });
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const chalk_1 = __importDefault(require("chalk"));
7
+ const simple_git_1 = __importDefault(require("simple-git"));
8
+ const fzf_1 = require("../fzf");
9
+ async function selectCommit() {
10
+ const commits = await simple_git_1.default().log({ from: 'HEAD', to: 'origin/master' });
11
+ const selected = await fzf_1.fzfSelect({
12
+ prompt: 'Select commit(s) for PR:',
13
+ genValues: addOption => commits.all.forEach(commit => {
14
+ const shortHash = commit.hash.slice(0, 8);
15
+ const label = chalk_1.default `{red ${shortHash}} {blue [${commit.author_name}]} {white ${commit.message}}`;
16
+ addOption({ label, id: commit.hash, ...commit });
17
+ }),
18
+ });
19
+ const commitHashes = selected.map(commit => commit.hash);
20
+ console.log(commitHashes.join('\n'));
21
+ }
22
+ exports.default = selectCommit;
package/dist/index.js CHANGED
@@ -6,7 +6,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const yargs_1 = __importDefault(require("yargs"));
8
8
  const pr_1 = __importDefault(require("./cmd/pr"));
9
+ const select_commit_1 = __importDefault(require("./cmd/select-commit"));
9
10
  yargs_1.default(process.argv.slice(2))
10
11
  .command('pr', 'Create and update PRs', pr_1.default)
12
+ .command('select-commit', 'Select a commit hash', select_commit_1.default)
11
13
  .demandCommand(1, '')
12
14
  .parse();
package/dist/utils.js CHANGED
@@ -6,15 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.branchFromMessage = exports.getHubToken = exports.getRepoPath = exports.getRepoKey = void 0;
7
7
  const git_url_parse_1 = __importDefault(require("git-url-parse"));
8
8
  const js_yaml_1 = __importDefault(require("js-yaml"));
9
+ const simple_git_1 = __importDefault(require("simple-git"));
9
10
  const fs_1 = require("fs");
10
11
  const path_1 = __importDefault(require("path"));
11
- const git_1 = __importDefault(require("./git"));
12
12
  const BRANCH_PREFIX = 'evanpurkhiser/';
13
13
  /**
14
14
  * Get's the current repo information
15
15
  */
16
16
  async function getRepoKey() {
17
- const url = await git_1.default.raw('config', '--get', 'remote.origin.url');
17
+ const url = await simple_git_1.default().raw('config', '--get', 'remote.origin.url');
18
18
  const repo = git_url_parse_1.default(url);
19
19
  const repoKey = {
20
20
  owner: repo.owner,
@@ -28,7 +28,7 @@ exports.getRepoKey = getRepoKey;
28
28
  * Get's the absolute path to the current git repo
29
29
  */
30
30
  async function getRepoPath() {
31
- const path = await git_1.default.revparse(['--show-toplevel']);
31
+ const path = await simple_git_1.default().revparse(['--show-toplevel']);
32
32
  return path.trim();
33
33
  }
34
34
  exports.getRepoPath = getRepoPath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evanpurkhiser/tooling-personal",
3
- "version": "1.11.0",
3
+ "version": "1.15.0",
4
4
  "description": "Evan Purkhiser's personal tooling",
5
5
  "repository": "https://github.com/EvanPurkhiser/tooling-personal",
6
6
  "author": "Evan Purkhiser",
package/dist/git.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const simple_git_1 = __importDefault(require("simple-git"));
7
- const git = simple_git_1.default();
8
- exports.default = git;