issue

package
v0.47.6 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package issue provides domain types and logic for the auto issue reporter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatMarkdown

func FormatMarkdown(report IssueReport) (string, error)

FormatMarkdown renders the issue report as a markdown string using the embedded issue-report.md.tmpl template.

func Sanitize

func Sanitize(s string) string

Sanitize applies SanitizePath, SanitizeSecrets, and SanitizeGitURL in sequence.

func SanitizeGitURL

func SanitizeGitURL(s string) string

SanitizeGitURL strips embedded credentials from HTTP/HTTPS git URLs.

func SanitizePath

func SanitizePath(s string) string

SanitizePath replaces the user's home directory prefix with $HOME.

func SanitizeSecrets

func SanitizeSecrets(s string) string

SanitizeSecrets redacts API keys, tokens, and secret environment variables.

Types

type CommandRunner

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

CommandRunner abstracts os/exec for testability.

type Config

type Config struct {
	Repo             string   `yaml:"repo"`
	Labels           []string `yaml:"labels"`
	AutoSubmit       bool     `yaml:"auto_submit"`
	RateLimitMinutes int      `yaml:"rate_limit_minutes"`
}

Config holds issue reporter configuration from autopus.yaml.

type IssueContext

type IssueContext struct {
	ErrorMessage string
	Command      string
	ExitCode     int
	OS           string
	GoVersion    string
	AutoVersion  string
	Platform     string
	ConfigYAML   string // sanitized autopus.yaml content
	Telemetry    string // recent pipeline run summary
}

IssueContext holds environment and error context for a report.

func CollectContext

func CollectContext(errMsg, cmd string, exitCode int) IssueContext

CollectContext gathers environment and error context for an issue report. It reads autopus.yaml and recent telemetry from the current working directory.

type IssueReport

type IssueReport struct {
	Title   string
	Context IssueContext
	Hash    string // xxhash hex string for dedup
	Labels  []string
	Repo    string // target GitHub repo (owner/repo)
}

IssueReport is a complete issue report ready for formatting.

type SubmitResult

type SubmitResult struct {
	IssueURL     string
	IssueNumber  int
	WasDuplicate bool
	Action       string // "created", "commented", "skipped"
}

SubmitResult holds the outcome of a GitHub issue submission.

type Submitter

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

Submitter orchestrates GitHub issue creation via the gh CLI.

func NewSubmitter

func NewSubmitter(runner CommandRunner) *Submitter

NewSubmitter creates a Submitter with the given CommandRunner. Pass nil to use the real os/exec runner.

func (*Submitter) AddComment

func (s *Submitter) AddComment(repo string, issueNum int, body string) error

AddComment adds a comment to an existing issue.

func (*Submitter) CheckGH

func (s *Submitter) CheckGH() error

CheckGH verifies that gh is installed and authenticated.

func (*Submitter) ComputeHash

func (s *Submitter) ComputeHash(errMsg, cmd string) string

ComputeHash returns the xxhash hex digest of (errMsg + command).

func (*Submitter) CreateIssue

func (s *Submitter) CreateIssue(repo, title, body string, labels []string) (SubmitResult, error)

CreateIssue creates a new GitHub issue and returns the result.

func (*Submitter) FindDuplicate

func (s *Submitter) FindDuplicate(repo, hash string) (string, error)

FindDuplicate searches for an existing issue with the given hash label. Returns the issue URL if found, or empty string if not found.

func (*Submitter) Submit

func (s *Submitter) Submit(report IssueReport, body string) (SubmitResult, error)

Submit orchestrates CheckGH → hash → FindDuplicate → CreateIssue or AddComment.

Jump to

Keyboard shortcuts

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