gityo 1.1.6 → 1.1.8

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.
Files changed (2) hide show
  1. package/dist/index.js +49 -21
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1710,7 +1710,7 @@ function useColor() {
1710
1710
  if (process$1.env.FORCE_COLOR || process$1.env.CLICOLOR_FORCE !== void 0) return true;
1711
1711
  }
1712
1712
  new Command();
1713
- var version$4 = "1.1.6";
1713
+ var version$4 = "1.1.8";
1714
1714
  const keybindingLookup = new Set(["emacs", "vim"]);
1715
1715
  function isKeybinding(value) {
1716
1716
  return keybindingLookup.has(value);
@@ -228985,6 +228985,7 @@ async function mainController(options = {}) {
228985
228985
  if (typeof options.input === "string" && finalCommitMessage.length === 0) throw new Error("Provided commit message input cannot be empty.");
228986
228986
  const { diffScope, files } = await getCommitFiles(git, options.scope ?? "staged-or-changes");
228987
228987
  if (files.length === 0) return console.log("No changed files found.");
228988
+ console.log(source_default.dim(`${files.length} ${diffScope === "staged" ? "staged" : "changed"} file(s)`));
228988
228989
  const diff = await getCommitDiff(git, diffScope);
228989
228990
  if (finalCommitMessage.length > 0) {
228990
228991
  console.log(source_default.yellow("✓ Using direct commit message"));
@@ -229135,6 +229136,21 @@ function toSpawnError(command, error$125) {
229135
229136
  if (error$125.code === "ENOENT") return /* @__PURE__ */ new Error(`'${command}' was not found. Install it and make sure it is on your PATH.`);
229136
229137
  return error$125;
229137
229138
  }
229139
+ const PULL_REQUEST_QUERY = `
229140
+ query($owner: String!, $name: String!, $base: String!, $head: String!) {
229141
+ repository(owner: $owner, name: $name) {
229142
+ pullRequests(first: 100, states: OPEN, baseRefName: $base, headRefName: $head) {
229143
+ nodes {
229144
+ number
229145
+ url
229146
+ baseRefName
229147
+ headRefName
229148
+ commits { totalCount }
229149
+ }
229150
+ }
229151
+ }
229152
+ }
229153
+ `;
229138
229154
  async function getDefaultBranch() {
229139
229155
  return (await exec("gh", [
229140
229156
  "repo",
@@ -229150,22 +229166,29 @@ async function fetchCompare(base$2, head$1) {
229150
229166
  }
229151
229167
  async function findPullRequest(base$2, head$1) {
229152
229168
  const matches = (await ghJson([
229153
- "pr",
229154
- "list",
229155
- "--state",
229156
- "open",
229157
- "--base",
229158
- base$2,
229159
- "--head",
229160
- head$1,
229161
- "--limit",
229162
- "100",
229163
- "--json",
229164
- "number,url,baseRefName,headRefName"
229165
- ])).filter((pullRequest) => pullRequest.baseRefName === base$2 && pullRequest.headRefName === head$1);
229169
+ "api",
229170
+ "graphql",
229171
+ "-f",
229172
+ `query=${PULL_REQUEST_QUERY}`,
229173
+ "-F",
229174
+ "owner={owner}",
229175
+ "-F",
229176
+ "name={repo}",
229177
+ "-F",
229178
+ `base=${base$2}`,
229179
+ "-F",
229180
+ `head=${head$1}`
229181
+ ])).data.repository.pullRequests.nodes.filter((pullRequest) => pullRequest.baseRefName === base$2 && pullRequest.headRefName === head$1);
229166
229182
  if (matches.length === 0) return null;
229167
229183
  if (matches.length > 1) throw new Error(`Multiple open pull requests found for ${base$2} <- ${head$1}.`);
229168
- return matches[0];
229184
+ const match = matches[0];
229185
+ return {
229186
+ number: match.number,
229187
+ url: match.url,
229188
+ baseRefName: match.baseRefName,
229189
+ headRefName: match.headRefName,
229190
+ commitCount: match.commits.totalCount
229191
+ };
229169
229192
  }
229170
229193
  async function createPullRequest$1(input$3) {
229171
229194
  return exec("gh", [
@@ -236220,6 +236243,7 @@ async function createPullRequest(options) {
236220
236243
  const maxDiffTokens = options.maxDiffTokens ?? DEFAULT_MAX_DIFF_TOKENS;
236221
236244
  const compare = await fetchCompare(options.base, options.head);
236222
236245
  if (compare.commits.length === 0) throw new Error(`No commits found between '${options.base}' and '${options.head}'.`);
236246
+ console.log(source_default.dim(`${compare.commits.length} commit(s) between ${options.base} and ${options.head}`));
236223
236247
  const context = buildCompareContext(compare, maxDiffTokens);
236224
236248
  let draft = "";
236225
236249
  while (true) {
@@ -236240,7 +236264,7 @@ async function createPullRequest(options) {
236240
236264
  body: content.body,
236241
236265
  base: options.base,
236242
236266
  head: options.head
236243
- }), options);
236267
+ }), options, compare.commits.length);
236244
236268
  console.log(pullRequest.url);
236245
236269
  return pullRequest;
236246
236270
  }
@@ -236251,13 +236275,14 @@ function parsePullRequestContent(text$1) {
236251
236275
  body: lines.slice(1).join("\n").trim()
236252
236276
  };
236253
236277
  }
236254
- async function resolveCreatedPullRequest(output$3, options) {
236278
+ async function resolveCreatedPullRequest(output$3, options, commitCount) {
236255
236279
  const match = output$3.match(PR_URL_PATTERN);
236256
236280
  if (match) return {
236257
236281
  number: Number(match[1]),
236258
236282
  url: match[0],
236259
236283
  baseRefName: options.base,
236260
- headRefName: options.head
236284
+ headRefName: options.head,
236285
+ commitCount
236261
236286
  };
236262
236287
  const found = await findPullRequest(options.base, options.head);
236263
236288
  if (found) return found;
@@ -236341,8 +236366,10 @@ async function mergePullRequestController(baseArg, headArg, options = {}) {
236341
236366
  scope: options.all ? "everything" : "staged-or-changes"
236342
236367
  });
236343
236368
  let pullRequest = await findPullRequest(branches.base, branches.head);
236344
- if (pullRequest) console.log(pullRequest.url);
236345
- else pullRequest = await createPullRequest({
236369
+ if (pullRequest) {
236370
+ console.log(source_default.dim(`${pullRequest.commitCount} commit(s) between ${branches.base} and ${branches.head}`));
236371
+ console.log(pullRequest.url);
236372
+ } else pullRequest = await createPullRequest({
236346
236373
  base: branches.base,
236347
236374
  head: branches.head,
236348
236375
  systemPrompt,
@@ -236361,6 +236388,7 @@ async function mergePullRequestController(baseArg, headArg, options = {}) {
236361
236388
  return;
236362
236389
  }
236363
236390
  await mergePullRequest(pullRequest.number, options.mergeMethod ?? context.config.prMergeMethod);
236391
+ if (options.web) await openPullRequest(pullRequest.number);
236364
236392
  }
236365
236393
  const toZeroIfInfinity = (value) => Number.isFinite(value) ? value : 0;
236366
236394
  function parseNumber(milliseconds) {
@@ -236941,7 +236969,7 @@ const pr = app.command("pr").description("Create and merge GitHub pull requests.
236941
236969
  pr.command("create").description("Create a pull request with an AI-generated title and body.").argument("[base-branch]", "Base branch to merge into (defaults to the repository default branch).").argument("[head-branch]", "Head branch with the changes (defaults to the current branch).").option("--model <model>", "Model key from config to use (overrides the configured model).").option("-t, --title-style <style>", "Title style key to use (defaults to \"default\").").option("-b, --body-style <style>", "Body style key to use (defaults to \"default\").").option("-y, --yolo", "Create the pull request without asking for confirmation.").option("-A, --all", "Commit all local changes, not just staged files, before continuing.").option("-w, --web", "Open the pull request in a browser.").action((baseBranch, headBranch, options) => {
236942
236970
  handleError(() => createPullRequestController(baseBranch, headBranch, options));
236943
236971
  });
236944
- pr.command("merge").description("Create the pull request if needed, then merge it.").argument("[base-branch]", "Base branch to merge into (defaults to the repository default branch).").argument("[head-branch]", "Head branch with the changes (defaults to the current branch).").option("--model <model>", "Model key from config to use (overrides the configured model).").option("-t, --title-style <style>", "Title style key to use (defaults to \"default\").").option("-b, --body-style <style>", "Body style key to use (defaults to \"default\").").option("-y, --yolo", "Merge the pull request without asking for confirmation.").option("-A, --all", "Commit all local changes, not just staged files, before continuing.").option("-m, --merge", "Merge the commits with the base branch.").option("-r, --rebase", "Rebase the commits onto the base branch.").option("-s, --squash", "Squash the commits into one commit.").action((baseBranch, headBranch, options) => {
236972
+ pr.command("merge").description("Create the pull request if needed, then merge it.").argument("[base-branch]", "Base branch to merge into (defaults to the repository default branch).").argument("[head-branch]", "Head branch with the changes (defaults to the current branch).").option("--model <model>", "Model key from config to use (overrides the configured model).").option("-t, --title-style <style>", "Title style key to use (defaults to \"default\").").option("-b, --body-style <style>", "Body style key to use (defaults to \"default\").").option("-y, --yolo", "Merge the pull request without asking for confirmation.").option("-A, --all", "Commit all local changes, not just staged files, before continuing.").option("-m, --merge", "Merge the commits with the base branch.").option("-r, --rebase", "Rebase the commits onto the base branch.").option("-s, --squash", "Squash the commits into one commit.").option("-w, --web", "Open the pull request in a browser after merging.").action((baseBranch, headBranch, options) => {
236945
236973
  if ([
236946
236974
  options.merge,
236947
236975
  options.rebase,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gityo",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/NazmusSayad/gityo.git"