utils

package
v1.45.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDirPerms = 0o750

DefaultDirPerms defines directory permissions for created paths.

View Source
const DefaultFilePerms = 0o600

DefaultFilePerms defines file permissions for created files.

Variables

This section is empty.

Functions

func AuthorInitials added in v1.43.0

func AuthorInitials(name string) string

AuthorInitials returns initials for an author name.

func ExpandPath

func ExpandPath(path string) (string, error)

ExpandPath expands ~ and environment variables in a path.

func GenerateIssueWorktreeName

func GenerateIssueWorktreeName(issue *models.IssueInfo, template, generatedTitle string) string

GenerateIssueWorktreeName generates a worktree name from an issue using a template. Supports placeholders: {number}, {title}, {generated}

func GeneratePRWorktreeName

func GeneratePRWorktreeName(pr *models.PRInfo, template, generatedTitle string) string

GeneratePRWorktreeName generates a worktree name from a PR using a template. Supports placeholders: {number}, {title}, {generated}, {pr_author}

func GitURLToWebURL added in v1.43.0

func GitURLToWebURL(gitURL string) string

GitURLToWebURL converts a git remote URL to a web URL. Handles both SSH (git@github.com:user/repo.git) and HTTPS (https://github.com/user/repo.git) formats.

func RandomBranchName added in v1.26.0

func RandomBranchName() string

RandomBranchName returns a Docker-style adjective-noun name for temporary branches.

func SanitizeBranchName

func SanitizeBranchName(name string, maxLength int) string

SanitizeBranchName sanitizes a branch/title for use as a worktree directory name. - Converts to lowercase - Keeps only alphanumeric characters, replaces everything else with hyphens - Collapses consecutive hyphens - Trims leading/trailing hyphens - Optionally limits length (0 = no limit)

func SanitizePRURL added in v1.43.0

func SanitizePRURL(raw string) (string, error)

SanitizePRURL validates and normalises a pull request URL.

func WrapANSIContent added in v1.43.0

func WrapANSIContent(content string, width int) string

WrapANSIContent wraps terminal-styled content to the target width while preserving ANSI escape sequences.

Types

type CommitMeta added in v1.43.0

type CommitMeta struct {
	SHA     string
	Author  string
	Email   string
	Date    string
	Subject string
	Body    []string
}

CommitMeta is parsed commit metadata from a log entry.

func ParseCommitMeta added in v1.43.0

func ParseCommitMeta(raw string) CommitMeta

ParseCommitMeta parses a raw commit metadata string into its fields.

Jump to

Keyboard shortcuts

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