Skip to content
IAmRadekPublic

About

Highly opinionated tool for PR creation.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

21 Commits

Folders and files

Repository files navigation

git-pr

A highly opinionated CLI for creating GitHub pull requests with a consistent structure and automatic related PR tracking.

What It Does

  • detects or prompts for a ticket/tag
  • suggests or prompts for a base branch
  • opens one editor buffer seeded from a PR template
  • creates the PR through gh
  • updates the "Related PRs" section across matching PRs

The authoring flow is intentionally simple: no form fields, no placeholder prompts, one editable PR body.

Installation

git clone https://github.com/IAmRadek/git-pr.git
cd git-pr
cargo install --path .

Prerequisites

  • gh installed and authenticated, for GitHub repositories
  • glab installed and authenticated, for GitLab repositories
  • a git repository with at least one commit on the current branch

Configuration

Default config path:

~/.config/git-pr/config.yaml

You can override the config directory with --config or GIT_PR_CONFIG.

Generate a default config:

git-pr --init

If the config file exists, --init does not change it. It prints the default config, with a comment for each option. To save it, run git-pr --init > config.sample.yaml.

Example:

jira:
  url: "https://yourcompany.atlassian.net/browse/"

github:
  user: "your-username"

template:
  path: "/absolute/path/to/pull_request_template.md"
  body: |
    Related PRs:
    <!-- RELATED_PR -->
    <!-- /RELATED_PR -->

    ## Summary

    ## Changes

    ## Testing

  markers:
    related_pr_start: "<!-- RELATED_PR -->"
    related_pr_end: "<!-- /RELATED_PR -->"

Forges

git-pr chooses the forge from the host of the origin remote. github.com and gitlab.com need no entry. For another host, add it under forges:

forges:
  git.example.com: github
  gitlab.example.com: gitlab

If the host has no forge, git-pr stops with an error.

The GitLab forge uses glab. It assigns the merge request to you, uses .gitlab/merge_request_templates/Default.md as the template, and refers to related merge requests as group/project!12.

Plugins

The plugins section lists the plugins of each kind, in run order. These are the built-in defaults:

plugins:
  ticket_sources: [commit_tags]   # the first detected ticket wins
  draft_hooks: [template_body]    # run before and after the editor
  after_create: [related_prs]     # run after the PR step

If a list is missing, git-pr uses its defaults. An empty list turns that kind off. If a name is unknown, git-pr prints a warning and skips it.

Jira

The jira ticket source suggests tickets at the PR Tag: prompt. It runs the query in jira.jql and detects nothing. If its jira section or a token variable is wrong, git-pr prints a warning and skips it.

jira:
  url: "https://yourcompany.atlassian.net/browse/"   # the API address is the part before browse/
  kind: cloud                                        # or datacenter
  jql: "assignee = currentUser() AND statusCategory != Done ORDER BY updated DESC"
plugins:
  ticket_sources: [commit_tags, jira]

The token comes from the environment. Jira Cloud needs JIRA_USER (the account email) and JIRA_TOKEN (an API token). Data Center needs JIRA_TOKEN (a personal access token).

Template Resolution

The initial PR body is resolved in this order:

  1. .github/PULL_REQUEST_TEMPLATE.md in the current repository
  2. template.path from config
  3. template.body from config

Before the resolved template content, git-pr prepends ticket context, for example:

Ticket: TRACK-123
Jira: https://yourcompany.atlassian.net/browse/TRACK-123

If the resolved template does not already contain the related-PR marker block, git-pr also prepends:

<!-- RELATED_PR -->
<!-- /RELATED_PR -->

That prepended block is only a convenience. You can move or copy it anywhere in the template once the editor opens.

Usage

Create a PR:

git-pr

The flow is:

  1. detect or select the ticket
  2. select the base branch
  3. edit the full PR body in your editor
  4. optionally select reviewers

Update related PRs only:

git-pr --update-only

Dry run:

git-pr --dry-run

Related PR Markers

Related PR updates only touch the configured marker section:

<!-- RELATED_PR -->
<!-- /RELATED_PR -->

If those markers exist in the PR body, git-pr rewrites that block with links to matching PRs. The rest of the body is left as authored.

Project Structure

src/
├── app.rs
├── cli.rs
├── config.rs
├── error.rs
├── git.rs
├── github.rs
├── jira.rs
├── lib.rs
├── main.rs
├── pr.rs
├── tags.rs
├── template.rs
└── ui.rs

License

MIT License. See LICENSE.

About

Highly opinionated tool for PR creation.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages