import "@johnlindquist/kit";
const { Octokit } = await npm("octokit");
const UrlPattern = await npm("url-pattern");
const client = new Octokit({
auth: await env("GITHUB_PULLREQUEST_TOKEN"),
});
const repoPattern = new UrlPattern(
"(http(s)\\://)(:subdomain.):domain.:tld(\\::port)(/:owner)(/:repo)/pull(/:id)"
);
const tab = await getActiveTab("Brave");
const { owner, repo, id } = repoPattern.match(tab);
const res = await client.rest.pulls.get({
owner,
repo,
pull_number: id,
});
const { title, user, html_url } = res.data;
await copy(`%%tana%%
- ${title} #pull request
- Pull Request URL:: ${html_url}
- Github User:: ${user.login}
`);