Created
January 8, 2023 19:57
-
-
Save am1no/075bae6f2e8a432df30aa9b6a48dc826 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Name: tana-github | |
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} | |
`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment