Skip to content

Commit

Permalink
Allow passing a --base flag to gh pr create (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
schpet authored Nov 27, 2024
1 parent 0eb181b commit 281b87a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ issues and team pages. offers handy commands:

- `linear issue` open the issue in linear.app, based on the current git branch
- `linear issue print` print it to stdout
- `linear issue pr` create a nicely named pull request with [gh](https://cli.github.com/)
- `linear issue pr` create a nicely named pull request with
[gh](https://cli.github.com/)
- `linear team` view active issues assigned to you in the team

see [the full list of commands](#commands) below.
Expand Down
18 changes: 14 additions & 4 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { encodeBase64 } from "@std/encoding/base64";
import { renderMarkdown } from "@littletof/charmd";
import { basename } from "@std/path";


async function getCurrentBranch(): Promise<string> {
const process = new Deno.Command("git", {
args: ["symbolic-ref", "--short", "HEAD"],
Expand Down Expand Up @@ -193,7 +192,10 @@ const issueCommand = new Command()
}

const showSpinner = color && Deno.stdout.isTerminal();
const { title, description } = await fetchIssueDetails(issueId, showSpinner);
const { title, description } = await fetchIssueDetails(
issueId,
showSpinner,
);
const markdown = `# ${title}${description ? "\n\n" + description : ""}`;
if (color && Deno.stdout.isTerminal()) {
console.log(renderMarkdown(markdown));
Expand Down Expand Up @@ -239,15 +241,22 @@ const issueCommand = new Command()
})
.command("pull-request", "Create a GitHub pull request with issue details")
.alias("pr")
.action(async () => {
.option(
"--base <branch:string>",
"The branch into which you want your code merged",
)
.action(async ({ base }) => {
const issueId = await getIssueId();
if (!issueId) {
console.error(
"The current branch does not contain a valid linear issue id.",
);
Deno.exit(1);
}
const { title, url } = await fetchIssueDetails(issueId, Deno.stdout.isTerminal());
const { title, url } = await fetchIssueDetails(
issueId,
Deno.stdout.isTerminal(),
);

const process = new Deno.Command("gh", {
args: [
Expand All @@ -258,6 +267,7 @@ const issueCommand = new Command()
"--body",
url,
"--web",
...(base ? ["--base", base] : []),
],
stdin: "inherit",
stdout: "inherit",
Expand Down

0 comments on commit 281b87a

Please sign in to comment.