{"id":19808820,"url":"https://github.com/k-kinzal/pr","last_synced_at":"2025-05-01T07:32:52.404Z","repository":{"id":53024627,"uuid":"213808334","full_name":"k-kinzal/pr","owner":"k-kinzal","description":"PR operates multiple Pull Request","archived":false,"fork":false,"pushed_at":"2025-04-05T14:29:35.000Z","size":293,"stargazers_count":9,"open_issues_count":9,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-05T15:27:46.844Z","etag":null,"topics":["cli","github","pull-requests"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/k-kinzal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-09T03:04:22.000Z","updated_at":"2025-02-17T02:19:18.000Z","dependencies_parsed_at":"2024-02-08T15:31:08.554Z","dependency_job_id":"d0a071f8-8d6c-4d16-ae3a-62933020b954","html_url":"https://github.com/k-kinzal/pr","commit_stats":{"total_commits":87,"total_committers":5,"mean_commits":17.4,"dds":"0.26436781609195403","last_synced_commit":"60ce9143ab91a1da19c80d0e2b0e54a388af07c3"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-kinzal%2Fpr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-kinzal%2Fpr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-kinzal%2Fpr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-kinzal%2Fpr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/k-kinzal","download_url":"https://codeload.github.com/k-kinzal/pr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251840532,"owners_count":21652372,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","github","pull-requests"],"created_at":"2024-11-12T09:14:52.458Z","updated_at":"2025-05-01T07:32:52.134Z","avatar_url":"https://github.com/k-kinzal.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PR\n\n[![Release](https://img.shields.io/github/v/release/k-kinzal/pr.svg?style=flat-square)](https://github.com/k-kinzal/pr/releases/latest)\n[![CircleCI](https://circleci.com/gh/k-kinzal/pr.svg?style=shield)](https://circleci.com/gh/k-kinzal/pr)\n[![GolangCI](https://golangci.com/badges/github.com/k-kinzal/pr.svg)](https://golangci.com/r/github.com/k-kinzal/pr)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fk-kinzal%2Fpr.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fk-kinzal%2Fpr?ref=badge_shield)\n\nPR is a CLI tool that operates Pull Request on a rule-based basis.\n\n## Get Started\n\n```bash\n$ curl -L https://github.com/k-kinzal/pr/releases/download/v0.2.1/pr_linux_amd64.tar.gz | tar xz\n$ cp pr /usr/local/bin/pr\n$ pr --help\nPR operates multiple Pull Request\n\nUsage:\n  pr [flags]\n  pr [command]\n\nAvailable Commands:\n  assignee    Manipulate assignees that match a rule\n  check       Check if PR matches the rule and change PR status\n  help        Help about any command\n  label       Manipulate labels that match a rule\n  merge       Merge PR that matches a rule\n  review      Add review to PRs that match rules\n  show        Show PR that matches a rule\n  validate    Validate the rules\n\nFlags:\n      --exit-code      returns an exit code of 127 if no PR matches the rule\n  -h, --help           help for pr\n      --no-exit-code   always returns 0 even if an error occurs\n      --rate int       API call seconds rate limit (default 10)\n      --token string   personal access token to manipulate PR [GITHUB_TOKEN]\n      --version        version for pr\n\nUse \"pr [command] --help\" for more information about a command.\n```\n\n## Operations\n\n### Merge\n\nMerge PRs that match the rule.\n\n```bash\n$ pr merge [owner]/[repo] --with-statuses -l 'state == `\"open\"`' -l 'length(statuses[?state == `\"success\"`]) \u003e `3`'\n[...]\n```\n\n### Review\n\nAdd a review to PRs that match the rule.\n\n```bash\n$ pr review [owner]/[repo] --action \"approve\" --with-statuses -l 'state == `\"open\"`' -l 'length(statuses[?state == `\"success\"`]) \u003e `3`'\n[...]\n```\n\n`--action \"approve\"` adds approval to the PR that matches the rule.\n\n### Label\n\nAppend/Remove/Replace labels to PRs that match the rule.\n\n```bash\n$ pr label [owner]/[repo] -l 'state == `\"open\"`' --action \"append\" --label \"foo\"\n...\n$ pr label [owner]/[repo] -l 'state == `\"open\"`' --action \"remove\" --label \"foo\"\n...\n$ pr label [owner]/[repo] -l 'state == `\"open\"`' --action \"replace\" --label \"foo\"\n...\n```\n\n`--action \"append\"` appends the specified label to the PR that matches the rule.\n`--action \"remove\"` removes the label specified for the PR that matched the rule.\n`--action \"replace\"` replaces all labels on PR that match the rule with the specified label.\n\n### Assignee\n\nAppend/Remove/Replace assignees to PRs that match the rule.\n\n```bash\n$ pr assignees [owner]/[repo] -l 'state == `\"open\"`' --action \"append\" --assignee \"foo\"\n...\n$ pr assignees [owner]/[repo] -l 'state == `\"open\"`' --action \"remove\" --assignee \"foo\"\n...\n$ pr assignees [owner]/[repo] -l 'state == `\"open\"`' --action \"replace\" --assignee \"foo\"\n...\n```\n\n`--action \"append\"` appends the specified label to the PR that matches the rule.\n`--action \"remove\"` removes the label specified for the PR that matched the rule.\n`--action \"replace\"` replaces all labels on PR that match the rule with the specified label.\n\n### Check\n\nWhen the PR CLI is run on the CI, the rule status is displayed separately from the CI.\nThis is a solution to the problem where multiple CI statuses are displayed in GitHub Action.\n\n```bash\n$ pr check [owner]/[repo] -l 'number == `1`' -l 'state == `\"open\"`' -l 'length(statuses[?state == `\"success\"` \u0026\u0026 context == `\"ci/circleci: test\"`]) == `1`'\n[...]\n```\n\nCheck commands can perform conditional actions.\n\n```bash\n$ pr check [owner]/[repo] --merge -l 'number == `1`' -l 'state == `\"open\"`' -l 'length(statuses[?state == `\"success\"`]) == `1`'\n[...]\n```\n\nFor PR with `number == 1`, merge if the condition is met, or change status to pending if the condition is not met.\n\n### Show\n\nCheck the PR that matches the rule.\n\n```bash\n$ pr show [owner]/[repo] -l 'state == `\"open\"`'\n[...]\n```\n\nIf you want to make an error if there is no PR that matches the rule, specify `--exit-code``.\n\n```bash\n$ pr show [owner]/[repo] --exit-code -l 'number == `1`' -l 'state == `\"open\"`'\n[...]\n```\n\n### Validate\n\nValidate the rules.\n\n```bash\n$ pr validate [owner]/[repo] --with-statuses -l 'state == `\"open\"`' -l 'length(statuses[?state == `\"success\"`]) \u003e `0`' -l 'user.name == `\"github-action[bot]\"`'\n[x] state == `\"open\"`: 1 PRs matched the rules\n[x] length(statuses[?state == `\"success\"`]) \u003e `0`: 1 PRs matched the rules\n[ ] user.name == `\"github-action[bot]\"`: no PR matches the rule\n[]\n```\n\n## Rule Specification\n\n### JSON\n\n[JSON](https://github.com/k-kinzal/pr/blob/master/doc/spec.json)\n\nSee below for a detailed description of each item.\n\n- [Pull Requests](https://developer.github.com/v3/pulls/)\n- [Comments](https://developer.github.com/v3/pulls/comments/#list-comments-on-a-pull-request)\n- [Reviews](https://developer.github.com/v3/pulls/reviews/#list-reviews-on-a-pull-request)\n- [Commits](https://developer.github.com/v3/pulls/#list-commits-on-a-pull-request)\n- [Statuses](https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref)\n- [Checks](https://developer.github.com/v3/checks/runs/#list-check-runs-for-a-specific-ref)\n\n`\"comments\"`, `\"reviews\"`, `\"commits\"`, `\"statuses\"\"`, and `\"checks\"` cannot be used by default with PR link relation.\nIf the parameter is required, specify option `--with-comments`, `--with-reviews`, `--with-commits`, `--with-statuses`, `--with-checks` or `--with-all`.\n\nNOTE: `--with-all` options have very poor performance. Not recommended for uses other than debugging.\n\n### Rule Expression\n\nIn PR CLI, rules are specified using [JMESPath](http://jmespath.org/).\n\n```bash\n$ pr show [owner]/[repo] -l 'state == `\"open\"`' -l 'length(statuses[?state == `\"success\"`]) \u003e= 1'\n```\n\n```\n[?state == `\"open\"`] | [?length(statuses[?state == `\"success\"`]) \u003e= 1])]\n```\n\nThe specified rule is converted to an expression that combines [Filter Expression](http://jmespath.org/proposals/filter-expressions.html) with a pipe.\n\n#### Extend date string \n\nThe date string has been extended to be replaced with unix time.\n\n```bash\n$ pr show [owner]/[repo] -l 'now() == `\"2006-01-02T15:04:05Z\"`' -l 'now() \u003e `\"15:04:05\"`'\n```\n```\n[?`1571475658` \u003e= `1136214245`] | [?`1571475658` \u003e= `1571497445`]\n```\n\nIf the date is in the format `\"2006-01-02T15:04:05Z \"`, it will be treated as unix time.\nThe format of `\"15:04:05\"` is regarded as time and treated as unix time for the specified time of the day.\n\n### Extend Function\n\nIn pr, JMESPath can be extended to use original functions.\n\n#### now()\n\n```\n$ pr show [owner]/[repo] -l 'now() == `\"2006-01-02T15:04:05Z\"`'\n```\n\n`now()` returns the current unix time.\n\n### GitHub Action\n\nIf you execute PR CLI with [GitHub Action], the rules are automatically completed by event type.\n\n**Number completion**\n\n- pull_request\n- pull_request_review\n- pull_request_review_comment\n\n```\nnumber == `[Pull Request Number]`\n```\n\n**Head branch completion**\n- create\n- deployment\n- deployment_status\n- push\n- release\n\n```\nhead.ref == `\"[Branch Name]\"`\n```\n\n**SHA completion**\n- page_build\n- status\n\n```\nhead.sha == `\\\"[SHA]\\\"`\n```\n\nPlease see the [event trigger](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows) for details.\n\n## License\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fk-kinzal%2Fpr.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fk-kinzal%2Fpr?ref=badge_large)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-kinzal%2Fpr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk-kinzal%2Fpr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-kinzal%2Fpr/lists"}