model

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeItem

type ChangeItem struct {
	// The author of a commit
	AuthorRaw *string `json:"author"`

	// URL to author's GitHub profile
	AuthorURLRaw *string `json:"author_url"`

	// The commit title
	CommitMessageRaw *string `json:"commit_message"`

	// The commit date of the contribution (i.e. merge date)
	DateRaw *time.Time `json:"date"`

	// IsPullRaw determines if the commit was sourced from a pull request or directly committed to the branch
	IsPullRaw *bool `json:"is_pull"`

	// When IsPullRaw=true, this will point to the source of the pull request
	PullURLRaw *string `json:"pull_url"`

	// The commit's full SHA1 hash
	CommitHashRaw *string `json:"commit"`

	// The URL to the commit
	CommitURLRaw *string `json:"commit_url"`

	// An optional group identifier
	GroupRaw *string `json:"group"`
}

ChangeItem stores properties exposed to users for Changelog creation

func (*ChangeItem) Author

func (ci *ChangeItem) Author() string

Author or empty string

func (*ChangeItem) AuthorURL

func (ci *ChangeItem) AuthorURL() string

AuthorURL or empty string

func (*ChangeItem) CommitHash

func (ci *ChangeItem) CommitHash() string

CommitHash or empty string

func (*ChangeItem) CommitHashShort

func (ci *ChangeItem) CommitHashShort() string

CommitHashShort is first 10 characters of CommitHash, or CommitHash if it's already short

func (*ChangeItem) CommitURL

func (ci *ChangeItem) CommitURL() string

CommitURL or empty string

func (*ChangeItem) Date

func (ci *ChangeItem) Date() time.Time

Date or now

func (*ChangeItem) GoString

func (ci *ChangeItem) GoString() string

GoString displays debuggable format of ChangeItem

func (*ChangeItem) Group

func (ci *ChangeItem) Group() string

Group is the targeted group for a commit, or empty string

func (*ChangeItem) IsPull

func (ci *ChangeItem) IsPull() bool

IsPull or false

func (*ChangeItem) PullID

func (ci *ChangeItem) PullID() (string, error)

PullID is the numerical ID of a pull request, extracted from PullURL

func (*ChangeItem) PullURL

func (ci *ChangeItem) PullURL() string

PullURL or empty string

func (*ChangeItem) Title

func (ci *ChangeItem) Title() string

Title is the first line of a commit message, otherwise empty string

type Config

type Config struct {
	// Defines whether we resolve commits only or query additional information from pull requests
	ResolveType *ResolveType `json:"resolve" yaml:"resolve"`

	// The Owner (user or org) of the target repository
	Owner string `json:"owner"`

	// The target repository
	Repo string `json:"repo"`

	// A set of Grouping objects which allow to define groupings for changelog output.
	// Commits are associated with the first matching group.
	Groupings []Grouping `json:"groupings,omitempty"`

	// As set of square-bracket regex patterns, wrapped texts and/or labels to be excluded from output.
	// If the commit message or pr labels reference any text in this Exclude set, that commit
	// will be ignored.
	Exclude []string `json:"exclude,omitempty"`

	// Optional base url when targeting GitHub Enterprise
	Enterprise *string `json:"enterprise,omitempty"`

	// Custom template following Go text/template syntax
	// For more details, see https://golang.org/pkg/text/template/
	Template *string `json:"template,omitempty"`

	// SortDirection defines the order of commits within the changelog
	SortDirection *SortDirection `json:"sort"`

	// PreferLocal defines whether commits may be queried locally. Requires executing from within a Git repository.
	PreferLocal *bool `json:"local,omitempty"`

	// MaxCommits defines the maximum number of commits to be processed.
	MaxCommits *int `json:"max_commits,omitempty"`
}

Config provides a user with more robust options for Changelog configuration

func LoadOrNewConfig

func LoadOrNewConfig(path *string, owner string, repo string) *Config

LoadOrNewConfig will attempt to load path, otherwise returns a newly constructed config.

func (*Config) FindGroup

func (c *Config) FindGroup(commitMessage string) *string

FindGroup determines the grouping for a commit message based on configured patterns Note: Patterns are compiled on each call rather than cached. While this has a minor performance cost, it ensures correctness when Groupings or Exclude are modified after loading (since Config is a public type). The actual regex matching (re.Match) dominates the performance, not compilation.

func (*Config) GetMaxCommits

func (c *Config) GetMaxCommits() int

GetMaxCommits returns the user-specified preference for maximum commit count, otherwise the default of 500

func (*Config) GetPreferLocal

func (c *Config) GetPreferLocal() bool

GetPreferLocal returns the user-specified preference for local commit querying, otherwise the default of 'false'

func (*Config) Load

func (c *Config) Load(path string) error

Load a Config from path

func (*Config) ShouldExcludeByText

func (c *Config) ShouldExcludeByText(text *string) bool

ShouldExcludeByText checks if the given text matches any exclude pattern Note: Patterns are compiled on each call rather than cached. While this has a minor performance cost, it ensures correctness when Groupings or Exclude are modified after loading (since Config is a public type). The actual regex matching (re.Match) dominates the performance, not compilation.

func (*Config) String

func (c *Config) String() string

String displays a human readable representation of a Config

func (*Config) Validate added in v1.4.0

func (c *Config) Validate() error

Validate checks that required fields are set

type GitURLs

type GitURLs struct {
	CompareURL string // URL to compare different commits (e.g., on GitHub)
	DiffURL    string // URL to view the difference between two commits
	PatchURL   string // URL for a patch file generated from two commits
}

GitURLs contains locations commonly found in changelogs

type Grouping

type Grouping struct {
	// Name of the group, displayed in changelog output
	Name string `json:"name"`

	// Patterns to be evaluated for association in this group
	Patterns []string `json:"patterns"`
}

Grouping allows assigning a grouping name with a set of regex patterns or texts. These patterns are evaluated against commit titles and, if resolving pull requests, labels.

func (Grouping) String added in v1.4.0

func (g Grouping) String() string

String returns a string representation of Grouping

type ResolveType

type ResolveType uint8

ResolveType is a type alias representing the enumeration of options which configure how commits are processed (if commit only or if we lookup any available pull request info)

const (
	// Commits only
	Commits ResolveType = 1 << iota
	// PullRequests requests that we pull PR information if available
	PullRequests ResolveType = 1 << iota
)

func (*ResolveType) MarshalJSON

func (r *ResolveType) MarshalJSON() ([]byte, error)

MarshalJSON converts ResolveType into a string representation sufficient for JSON

func (*ResolveType) MarshalYAML added in v1.1.0

func (r *ResolveType) MarshalYAML() ([]byte, error)

func (ResolveType) Ptr

func (r ResolveType) Ptr() *ResolveType

func (ResolveType) String

func (r ResolveType) String() string

String displays a human readable representation of the ResolveType values

func (*ResolveType) UnmarshalJSON

func (r *ResolveType) UnmarshalJSON(b []byte) error

UnmarshalJSON converts a JSON formatted character array into ResolveType

func (*ResolveType) UnmarshalYAML added in v1.1.0

func (r *ResolveType) UnmarshalYAML(b []byte) error

type SortDirection

type SortDirection uint8
const (
	// Descending means most recent commits are at the top of the changelog
	Descending SortDirection = 1 << iota

	// Ascending means earlier commits are at the top of the changelog, more recent are at the bottom
	Ascending SortDirection = 1 << iota
)

func (*SortDirection) MarshalJSON

func (s *SortDirection) MarshalJSON() ([]byte, error)

MarshalJSON converts SortDirection into a string representation sufficient for JSON

func (*SortDirection) MarshalYAML added in v1.1.0

func (s *SortDirection) MarshalYAML() ([]byte, error)

func (SortDirection) Ptr

func (s SortDirection) Ptr() *SortDirection

func (SortDirection) String

func (s SortDirection) String() string

String displays a human readable representation of the SortDirection values

func (*SortDirection) UnmarshalJSON

func (s *SortDirection) UnmarshalJSON(b []byte) error

UnmarshalJSON converts a JSON formatted character array into SortDirection

func (*SortDirection) UnmarshalYAML added in v1.1.0

func (s *SortDirection) UnmarshalYAML(b []byte) error

type TemplateData

type TemplateData struct {
	Version         string
	PreviousVersion string
	Items           []ChangeItem
	DiffURL         string
	PatchURL        string
	CompareURL      string
	Grouped         []TemplateGroup
}

TemplateData is the structure(s) bound to templates See https://golang.org/pkg/text/template/ for template details

type TemplateGroup

type TemplateGroup struct {
	Name  string
	Items []ChangeItem
}

TemplateGroup allows for data to be grouped in order as defined by user config

Jump to

Keyboard shortcuts

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