@evanpurkhiser/tooling-personal 1.16.0 → 1.17.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
@@ -14,6 +14,7 @@ const pulls_1 = require("../pulls");
14
14
  const utils_1 = require("../utils");
15
15
  const getCommits = () => simple_git_1.default().log({ from: 'HEAD', to: 'origin/master' });
16
16
  async function pr() {
17
+ const username = await utils_1.getEmailUsername();
17
18
  const repo = await utils_1.getRepoKey();
18
19
  const rendererOptions = { showTimer: true };
19
20
  const collectInfoTask = new listr2_1.Listr([], {
@@ -53,7 +54,7 @@ async function pr() {
53
54
  const selectCommits = () => fzf_1.fzfSelect({
54
55
  prompt: 'Select commit(s) for PR:',
55
56
  genValues: addOption => commits.all.forEach(commit => {
56
- const branchName = utils_1.branchFromMessage(commit.message);
57
+ const branchName = utils_1.branchFromMessage(username, commit.message);
57
58
  const pr = prs.find(pr => pr.headRefName === branchName);
58
59
  const existingPrLabel = pr !== undefined ? chalk_1.default.yellowBright `(updates #${pr.number})` : '';
59
60
  const shortHash = commit.hash.slice(0, 8);
@@ -79,7 +80,7 @@ async function pr() {
79
80
  .map(sha => `pick ${sha}`)
80
81
  .join('\n');
81
82
  const targetCommit = selectedCommits[selectedCommits.length - 1];
82
- const branchName = utils_1.branchFromMessage(targetCommit.message);
83
+ const branchName = utils_1.branchFromMessage(username, targetCommit.message);
83
84
  const willOpenPr = prs.some(pr => pr.headRefName === branchName);
84
85
  // 03. Rebase and push the selected commits
85
86
  const doRebase = async () => {
package/dist/utils.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.branchFromMessage = exports.getHubToken = exports.getRepoPath = exports.getRepoKey = void 0;
6
+ exports.branchFromMessage = exports.getHubToken = exports.getRepoPath = exports.getEmailUsername = 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
9
  const simple_git_1 = __importDefault(require("simple-git"));
@@ -24,6 +24,14 @@ async function getRepoKey() {
24
24
  return repoKey;
25
25
  }
26
26
  exports.getRepoKey = getRepoKey;
27
+ /**
28
+ * Get the git username from email
29
+ */
30
+ async function getEmailUsername() {
31
+ const email = await simple_git_1.default().raw('config', '--get', 'user.email');
32
+ return email.split('@')[0].toLowerCase();
33
+ }
34
+ exports.getEmailUsername = getEmailUsername;
27
35
  /**
28
36
  * Get's the absolute path to the current git repo
29
37
  */
@@ -44,7 +52,7 @@ exports.getHubToken = getHubToken;
44
52
  /**
45
53
  * Generates a consistent branch name from a commit message
46
54
  */
47
- function branchFromMessage(commitMessage) {
55
+ function branchFromMessage(prefix, commitMessage) {
48
56
  const branch = commitMessage
49
57
  .toLowerCase()
50
58
  .replaceAll(/[^0-9a-zA-Z]/g, '-')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evanpurkhiser/tooling-personal",
3
- "version": "1.16.0",
3
+ "version": "1.17.0",
4
4
  "description": "Evan Purkhiser's personal tooling",
5
5
  "repository": "https://github.com/EvanPurkhiser/tooling-personal",
6
6
  "author": "Evan Purkhiser",