git

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: Apache-2.0 Imports: 27 Imported by: 2

Documentation

Index

Constants

View Source
const (
	GIT       = "git"
	LOG       = "log"
	SHOW      = "show"
	REVPARSE  = "rev-parse"
	TOPLEVEL  = "--show-toplevel"
	NOPAGER   = "--no-pager"
	FOLLOW    = "--follow"
	LOGFORMAT = "--pretty=%cD||%h||%s||%an||%ae"
	NUMBER    = "-n"
	DIV       = "--"
)
View Source
const GithubToken = "GH_TOKEN"

Variables

This section is empty.

Functions

func BuildChangelog added in v0.1.0

func BuildChangelog(commitHistory []*model.Commit,
	progressChan chan *model.ProgressUpdate, errorChan chan model.ProgressError,
	opts HistoryOptions, breakingConfig *whatChangedModel.BreakingRulesConfig,
) ([]*model.Commit, []error)

BuildChangelog compares consecutive commits and populates each with parsed documents and change data. Set opts.KeepComparable to preserve revisions even when the legacy libopenapi diff is empty.

func BuildRevisionDocumentConfiguration added in v0.2.2

func BuildRevisionDocumentConfiguration(ctx *RevisionDocumentContext, revision string,
	baseDocConfig *datamodel.DocumentConfiguration,
) (*datamodel.DocumentConfiguration, error)

func CanonicalizePath added in v0.2.2

func CanonicalizePath(path string) (string, error)

func CheckLocalRepoAvailable

func CheckLocalRepoAvailable(dir string) bool

func ExtractHistoryFromFile

func ExtractHistoryFromFile(repoDirectory, filePath string,
	progressChan chan *model.ProgressUpdate, errorChan chan model.ProgressError, opts HistoryOptions,
) ([]*model.Commit, []error)

func ExtractPathAndFile

func ExtractPathAndFile(location string) (string, string)

func GetTopLevel

func GetTopLevel(dir string) (string, error)

func NewRepoRelativeDocumentPathRewriter added in v0.2.2

func NewRepoRelativeDocumentPathRewriter(repoRoot, basePath string) model.DocumentPathRewriter

func PopulateHistory added in v0.1.0

func PopulateHistory(commitHistory []*model.Commit,
	progressChan chan *model.ProgressUpdate, errorChan chan model.ProgressError,
	opts HistoryOptions, breakingConfig *whatChangedModel.BreakingRulesConfig,
) ([]*model.Commit, []error)

func ProcessGithubRepo

func ProcessGithubRepo(username, repo, filePath string,
	progressChan chan *model.ProgressUpdate, errorChan chan model.ProgressError,
	opts HistoryOptions, breakingConfig *whatChangedModel.BreakingRulesConfig,
) ([]*model.Commit, []error)

func ReadFileAtRevision added in v0.2.2

func ReadFileAtRevision(repoDir, revision, filePath string) ([]byte, error)

ReadFileAtRevision reads a file from a git repository at the given revision.

func ResolveBaseOverride added in v0.2.2

func ResolveBaseOverride(base string) (string, *url.URL, error)

Types

type GitRevisionFS added in v0.2.2

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

func NewGitRevisionFS added in v0.2.2

func NewGitRevisionFS(repoRoot, baseDir, revision string, docConfig *datamodel.DocumentConfiguration) (*GitRevisionFS, error)

func (*GitRevisionFS) GetFiles added in v0.2.2

func (g *GitRevisionFS) GetFiles() map[string]index.RolodexFile

func (*GitRevisionFS) Open added in v0.2.2

func (g *GitRevisionFS) Open(name string) (fs.File, error)

func (*GitRevisionFS) SetLogger added in v0.2.2

func (g *GitRevisionFS) SetLogger(logger *slog.Logger)

func (*GitRevisionFS) SetRolodex added in v0.2.2

func (g *GitRevisionFS) SetRolodex(rolodex *index.Rolodex)

type HistoryBuildResult added in v0.2.3

type HistoryBuildResult struct {
	Commits        []*model.Commit
	SkippedCommits []string
}

HistoryBuildResult contains the comparable commit history produced by the git/GitHub normalization layer plus any skipped revisions.

func PopulateHistoryDetailed added in v0.2.3

func PopulateHistoryDetailed(commitHistory []*model.Commit,
	progressChan chan *model.ProgressUpdate, errorChan chan model.ProgressError,
	opts HistoryOptions, breakingConfig *whatChangedModel.BreakingRulesConfig,
) (*HistoryBuildResult, []error)

PopulateHistory reads file data from git for each commit, then builds the changelog. Set opts.KeepComparable to preserve revisions even when the legacy libopenapi diff is empty (used by the doctor/changerator-based commands).

func ProcessGithubRepoDetailed added in v0.2.3

func ProcessGithubRepoDetailed(username, repo, filePath string,
	progressChan chan *model.ProgressUpdate, errorChan chan model.ProgressError,
	opts HistoryOptions, breakingConfig *whatChangedModel.BreakingRulesConfig,
) (*HistoryBuildResult, []error)

ProcessGithubRepo fetches file history from GitHub and builds the commit changelog. Set opts.KeepComparable to preserve revisions even when the legacy libopenapi diff is empty.

type HistoryOptions added in v0.1.0

type HistoryOptions struct {
	Base            string
	Remote          bool
	ExtRefs         bool
	KeepComparable  bool // true = preserve Documents on commits even when legacy diff is empty
	Limit           int
	LimitTime       int
	ForceCutoff     bool // GitHub only
	GlobalRevisions bool // ExtractHistoryFromFile only
	BaseCommit      string
}

HistoryOptions controls how git history is fetched, traversed, and compared. BreakingConfig is intentionally kept as a separate parameter in function signatures — it controls comparison semantics, not history traversal.

type RevisionDocumentContext added in v0.2.2

type RevisionDocumentContext struct {
	RepoRoot         string
	RepoFilePath     string
	SpecFilePath     string
	BasePath         string
	BaseURL          *url.URL
	DocumentRewriter model.DocumentPathRewriter
}

func BuildRevisionDocumentContext added in v0.2.2

func BuildRevisionDocumentContext(repoDir, filePath, basePathOverride string, baseURLOverride *url.URL) (*RevisionDocumentContext, error)

Jump to

Keyboard shortcuts

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