Documentation
¶
Overview ¶
Package issuelib provides the core library for git-issue.
Index ¶
- Constants
- func ClosedRefForID(id int64) string
- func Contains(slice []string, item string) bool
- func FormatID(id int64) string
- func FormatOneLiner(issue *Issue) string
- func IsClosedRef(ref string) bool
- func ParseID(s string) (int64, error)
- func RefForID(id int64) string
- func StatusColor(status string) string
- func StatusFromRef(ref string) string
- type GitStore
- func (s *GitStore) AddNote(commit, content string) error
- func (s *GitStore) Create(title, description string) (*Issue, error)
- func (s *GitStore) Fetch(remote string, refspecs []string) error
- func (s *GitStore) FindRef(id int64) (string, error)
- func (s *GitStore) Get(id int64) (*Issue, string, error)
- func (s *GitStore) GetByRef(ref string) (*Issue, string, error)
- func (s *GitStore) GetCommitInfo(sha string) (string, error)
- func (s *GitStore) GetNextID() (int64, error)
- func (s *GitStore) GetNotes(commit string) (string, error)
- func (s *GitStore) GetTree(ref string) (map[string]string, error)
- func (s *GitStore) List(includeAll bool) ([]*Issue, error)
- func (s *GitStore) ListDir(ref, path string) (map[string]string, error)
- func (s *GitStore) ListRefs(includeAll bool) ([]string, error)
- func (s *GitStore) MoveRef(from, to string) error
- func (s *GitStore) Out() io.Writer
- func (s *GitStore) Push(remote string, refspecs []string) error
- func (s *GitStore) ReadFile(ref, path string) ([]byte, error)
- func (s *GitStore) Update(issue *Issue, message string, extraFiles map[string]string) error
- func (s *GitStore) VerifyCommit(commit string) (string, error)
- func (s *GitStore) VerifyRemote(remote string) error
- type Issue
- type Store
Constants ¶
const ( ColorGreen = "\033[32m" ColorGray = "\033[90m" ColorReset = "\033[0m" )
ANSI color codes
Variables ¶
This section is empty.
Functions ¶
func ClosedRefForID ¶
ClosedRefForID returns the ref path for a closed issue.
func FormatOneLiner ¶
FormatOneLiner formats an issue as a one-line summary.
func IsClosedRef ¶
IsClosedRef returns true if the ref is for a closed issue.
func StatusColor ¶
StatusColor returns the ANSI color code for a status.
func StatusFromRef ¶
StatusFromRef determines the status based on the ref path.
Types ¶
type GitStore ¶
type GitStore struct {
// contains filtered or unexported fields
}
GitStore implements Store using git refs and objects.
func NewGitStoreWithOutput ¶
NewGitStoreWithOutput creates a GitStore with custom output.
func (*GitStore) GetCommitInfo ¶
GetCommitInfo returns the short commit info.
func (*GitStore) VerifyCommit ¶
VerifyCommit verifies a commit exists.
func (*GitStore) VerifyRemote ¶
VerifyRemote checks if a remote exists.
type Issue ¶
type Issue struct {
ID int64 `tony:"field=id"`
Status string `tony:"field=status"`
Created time.Time `tony:"field=created"`
Updated time.Time `tony:"field=updated"`
Commits []string `tony:"field=commits"`
Branches []string `tony:"field=branches"`
ClosedBy *string `tony:"field=closed_by, optional"`
RelatedIssues []string `tony:"field=related_issues"`
Blocks []string `tony:"field=blocks"`
BlockedBy []string `tony:"field=blocked_by"`
Duplicates []string `tony:"field=duplicates"`
// Derived fields (not serialized in meta.tony)
Ref string // The git ref (e.g., "refs/issues/000001")
Title string // From description.md first line
}
func (*Issue) FromTony ¶
func (s *Issue) FromTony(data []byte, opts ...gomap.UnmapOption) error
FromTony parses Tony format bytes and populates Issue.
func (*Issue) FromTonyIR ¶
FromTonyIR populates Issue from a Tony IR node.
type Store ¶
type Store interface {
// GetNextID allocates and returns the next issue ID.
GetNextID() (int64, error)
// Create creates a new issue with the given title and description.
// Returns the created issue with ID populated.
Create(title, description string) (*Issue, error)
// Get retrieves an issue by ID, searching both open and closed refs.
// Returns the issue, description content, and any error.
Get(id int64) (*Issue, string, error)
// GetByRef retrieves an issue by its git ref.
// Returns the issue, description content, and any error.
GetByRef(ref string) (*Issue, string, error)
// FindRef finds the ref for an issue ID, checking both open and closed.
// Returns the ref path or error if not found.
FindRef(id int64) (string, error)
// Update updates an issue's metadata and optionally additional files.
// The issue.Ref must be set. The message is used for the commit.
Update(issue *Issue, message string, extraFiles map[string]string) error
// List returns all issues, optionally including closed ones.
List(includeAll bool) ([]*Issue, error)
// ListRefs returns all issue refs, optionally including closed ones.
ListRefs(includeAll bool) ([]string, error)
// MoveRef moves an issue from one ref to another (e.g., close issue).
MoveRef(from, to string) error
// ReadFile reads a file from an issue's tree.
ReadFile(ref, path string) ([]byte, error)
// GetCommitInfo returns the short commit info for a SHA.
GetCommitInfo(sha string) (string, error)
// VerifyCommit verifies a commit exists and returns its full SHA.
VerifyCommit(commit string) (string, error)
// AddNote adds a git note to a commit.
AddNote(commit, content string) error
// GetNotes returns the git notes for a commit.
GetNotes(commit string) (string, error)
// Push pushes refs to a remote.
Push(remote string, refspecs []string) error
// Fetch fetches refs from a remote.
Fetch(remote string, refspecs []string) error
// VerifyRemote checks if a remote exists.
VerifyRemote(remote string) error
// Out returns the output writer for this store.
Out() io.Writer
}
Store defines the interface for issue storage operations.