githelper

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommitURL

func CommitURL(repo, sha string) string

CommitURL constructs a GitHub commit URL from repo slug and SHA.

func TaskIDFromBranch

func TaskIDFromBranch(branch string) string

TaskIDFromBranch extracts a ClickUp task ID from a git branch name.

Patterns matched (in order):

  1. "CU-abc123-description" → "abc123" (ClickUp native ID)
  2. "feature/CU-abc123-desc" → "abc123" (with branch prefix)
  3. "PROJ-42-description" → "PROJ-42" (custom task ID)
  4. "feature/PROJ-42-desc" → "PROJ-42" (with branch prefix)

Returns "" if no task ID pattern is found.

Types

type CommandRunner

type CommandRunner interface {
	Run(ctx context.Context, name string, args ...string) ([]byte, error)
}

CommandRunner abstracts running external commands for testability.

type CommitInfo

type CommitInfo struct {
	SHA     string
	Subject string
}

CommitInfo holds metadata about a git commit.

type Helper

type Helper struct {
	Runner CommandRunner
}

Helper provides git and gh CLI operations.

func (*Helper) CurrentBranch

func (h *Helper) CurrentBranch(ctx context.Context) (string, error)

CurrentBranch returns the current git branch name.

func (*Helper) GetCommitInfo

func (h *Helper) GetCommitInfo(ctx context.Context, sha string) (*CommitInfo, error)

GetCommitInfo fetches commit metadata using git log. If sha is empty, defaults to HEAD.

func (*Helper) GetPRInfo

func (h *Helper) GetPRInfo(ctx context.Context, number int, repo string) (*PRInfo, error)

GetPRInfo fetches PR metadata using the gh CLI. If number is 0, it views the PR associated with the current branch. If repo is empty, gh uses the current repo.

func (*Helper) GetRepoSlug

func (h *Helper) GetRepoSlug(ctx context.Context) (string, error)

GetRepoSlug returns the owner/repo of the current repository via gh.

type OSCommandRunner

type OSCommandRunner struct{}

OSCommandRunner implements CommandRunner using os/exec.

func (OSCommandRunner) Run

func (OSCommandRunner) Run(ctx context.Context, name string, args ...string) ([]byte, error)

Run executes the command and returns its combined output.

type PRInfo

type PRInfo struct {
	Number int    `json:"number"`
	Title  string `json:"title"`
	URL    string `json:"url"`
}

PRInfo holds metadata about a GitHub pull request.

Jump to

Keyboard shortcuts

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