prdiff

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package prdiff provides utilities for interacting with GitHub pull requests, including resolving the merge-base commit SHA via the GitHub API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseOwnerRepo

func ParseOwnerRepo(remoteURL string) (owner, repo string, err error)

ParseOwnerRepo extracts the owner and repository name from a GitHub remote URL or a plain "owner/repo" string. It handles the following forms:

owner/repo
https://github.com/owner/repo
https://github.com/owner/repo.git
git@github.com:owner/repo.git
ssh://git@github.com/owner/repo.git

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client retrieves the merge-base commit SHA of a GitHub pull request.

func NewClient

func NewClient(token, baseURL string) (*Client, error)

NewClient initializes a GitHub API client. Pass an empty token for unauthenticated access (60 req/hour limit applies). Pass a non-empty baseURL to target a GitHub Enterprise instance instead of github.com.

func (*Client) GetMergeBase

func (c *Client) GetMergeBase(ctx context.Context, owner, repo string, number int) (string, error)

GetMergeBase returns the merge-base commit SHA between the base branch and the head commit of the given pull request number.

func (*Client) GetPRForBranch

func (c *Client) GetPRForBranch(ctx context.Context, owner, repo, branch string) (int, error)

GetPRForBranch returns the number of the open pull request whose head branch matches branch in the given repository. It uses the GitHub API to list open PRs filtered by head, matching the behavior of "gh pr view" with no number. Returns an error if no open PR is found for the branch.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL