types

package
v1.12.0-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UpToDate        ForkStatus = 0
	FastForwardable            = 1
	Conflict                   = 2
	MissingBranch              = 3
)

Variables

This section is empty.

Functions

func SeparateLines

func SeparateLines(fragment *gitdiff.TextFragment) ([]SplitLine, []SplitLine)

separate lines into left and right, this includes additional logic to group consecutive runs of additions and deletions in order to align them properly in the final output

TODO: move all diff stuff to a single package, we are spread across patchutil and types right now

Types

type AncestorCheckResponse

type AncestorCheckResponse struct {
	Status ForkStatus `json:"status"`
}

type Branch

type Branch struct {
	Reference `json:"reference"`
	Commit    *object.Commit `json:"commit,omitempty"`
	IsDefault bool           `json:"is_default,omitempty"`
}

func (*Branch) UnmarshalJSON

func (b *Branch) UnmarshalJSON(data []byte) error

type Capabilities

type Capabilities struct {
	PullRequests struct {
		FormatPatch       bool `json:"format_patch"`
		PatchSubmissions  bool `json:"patch_submissions"`
		BranchSubmissions bool `json:"branch_submissions"`
		ForkSubmissions   bool `json:"fork_submissions"`
	} `json:"pull_requests"`
}

type Commit

type Commit struct {
	// hash of the commit object.
	Hash plumbing.Hash `json:"hash,omitempty"`

	// author is the original author of the commit.
	Author object.Signature `json:"author"`

	// committer is the one performing the commit, might be different from author.
	Committer object.Signature `json:"committer"`

	// message is the commit message, contains arbitrary text.
	Message string `json:"message"`

	// treehash is the hash of the root tree of the commit.
	Tree string `json:"tree"`

	// parents are the hashes of the parent commits of the commit.
	ParentHashes []plumbing.Hash `json:"parent_hashes,omitempty"`

	// pgpsignature is the pgp signature of the commit.
	PGPSignature string `json:"pgp_signature,omitempty"`

	// mergetag is the embedded tag object when a merge commit is created by
	// merging a signed tag.
	MergeTag string `json:"merge_tag,omitempty"`

	// changeid is a unique identifier for the change (e.g., gerrit change-id).
	ChangeId string `json:"change_id,omitempty"`

	// extraheaders contains additional headers not captured by other fields.
	ExtraHeaders map[string][]byte `json:"extra_headers,omitempty"`

	// deprecated: kept for backwards compatibility with old json format.
	This string `json:"this,omitempty"`

	// deprecated: kept for backwards compatibility with old json format.
	Parent string `json:"parent,omitempty"`
}

func (Commit) CoAuthors

func (commit Commit) CoAuthors() []object.Signature

func (*Commit) FromGoGitCommit

func (c *Commit) FromGoGitCommit(gc *object.Commit)

fill in as much of Commit as possible from the given go-git commit

func (*Commit) Payload

func (c *Commit) Payload() string

produce a verifiable payload from this commit's metadata

func (*Commit) UnmarshalJSON

func (c *Commit) UnmarshalJSON(data []byte) error

types.Commit is an unify two commit structs:

  • git.object.Commit from
  • types.NiceDiff.commit

to do this in backwards compatible fashion, we define the base struct to use the same fields as NiceDiff.Commit, and then we also unmarshal the struct fields from go-git structs, this custom unmarshal makes sense of both representations and unifies them to have maximal data in either form.

type ConflictInfo

type ConflictInfo struct {
	Filename string `json:"filename"`
	Reason   string `json:"reason"`
}

type Diff

type Diff struct {
	Name struct {
		Old string `json:"old"`
		New string `json:"new"`
	} `json:"name"`
	TextFragments []gitdiff.TextFragment `json:"text_fragments"`
	IsBinary      bool                   `json:"is_binary"`
	IsNew         bool                   `json:"is_new"`
	IsDelete      bool                   `json:"is_delete"`
	IsCopy        bool                   `json:"is_copy"`
	IsRename      bool                   `json:"is_rename"`
}

func (Diff) CanRender

func (d Diff) CanRender() string

func (Diff) Id

func (d Diff) Id() string

func (Diff) Names

func (d Diff) Names() DiffFileName

func (Diff) Split

func (d Diff) Split() SplitDiff

func (Diff) Stats

func (d Diff) Stats() DiffFileStat

type DiffFileName

type DiffFileName struct {
	Old string
	New string
}

type DiffFileRenderer

type DiffFileRenderer interface {
	// html ID for each file in the diff
	Id() string

	// produce a splitdiff
	Split() SplitDiff

	// stats for this single file
	Stats() DiffFileStat

	// old and new name of file
	Names() DiffFileName

	// whether this diff can be displayed,
	// returns a reason if not, and the empty string if it can
	CanRender() string
}

type DiffFileStat

type DiffFileStat struct {
	Insertions int64
	Deletions  int64
}

type DiffOpts

type DiffOpts struct {
	Split bool `json:"split"`
}

func (DiffOpts) Encode

func (d DiffOpts) Encode() string

type DiffRenderer

type DiffRenderer interface {
	// list of file affected by these diffs
	ChangedFiles() []DiffFileRenderer

	// filetree
	FileTree() *filetree.FileTreeNode

	Stats() DiffStat
}

type DiffStat

type DiffStat struct {
	Insertions   int64 `json:"insertions"`
	Deletions    int64 `json:"deletions"`
	FilesChanged int   `json:"files_changed"`
}

type DiffTree

type DiffTree struct {
	Rev1  string          `json:"rev1"`
	Rev2  string          `json:"rev2"`
	Patch string          `json:"patch"`
	Diff  []*gitdiff.File `json:"diff"`
}

type ForkInfo

type ForkInfo struct {
	IsFork bool
	Status ForkStatus
}

type ForkStatus

type ForkStatus int

type FormatPatch

type FormatPatch struct {
	Files []*gitdiff.File
	*gitdiff.PatchHeader
	Raw string
}

func (FormatPatch) ChangeId

func (f FormatPatch) ChangeId() (string, error)

type LastCommitInfo

type LastCommitInfo struct {
	Hash    plumbing.Hash
	Message string
	When    time.Time
	Author  struct {
		Email string
		Name  string
		When  time.Time
	}
}

type MergeCheckResponse

type MergeCheckResponse struct {
	IsConflicted bool           `json:"is_conflicted"`
	Conflicts    []ConflictInfo `json:"conflicts"`
	Message      string         `json:"message"`
	Error        string         `json:"error"`
}

type MergeRequest

type MergeRequest struct {
	Patch         string `json:"patch"`
	AuthorName    string `json:"authorName,omitempty"`
	AuthorEmail   string `json:"authorEmail,omitempty"`
	CommitBody    string `json:"commitBody,omitempty"`
	CommitMessage string `json:"commitMessage,omitempty"`
	Branch        string `json:"branch"`
}

type NiceDiff

type NiceDiff struct {
	Commit Commit   `json:"commit"`
	Stat   DiffStat `json:"stat"`
	Diff   []Diff   `json:"diff"`
}

A nicer git diff representation.

func (NiceDiff) ChangedFiles

func (d NiceDiff) ChangedFiles() []DiffFileRenderer

func (NiceDiff) FileTree

func (d NiceDiff) FileTree() *filetree.FileTreeNode

func (NiceDiff) Stats

func (d NiceDiff) Stats() DiffStat

type NiceTree

type NiceTree struct {
	// Relative path
	Name string `json:"name"`
	Mode string `json:"mode"`
	Size int64  `json:"size"`

	LastCommit *LastCommitInfo `json:"last_commit,omitempty"`
}

A nicer git tree representation.

func (*NiceTree) FileMode

func (t *NiceTree) FileMode() (filemode.FileMode, error)

func (*NiceTree) IsFile

func (t *NiceTree) IsFile() bool

func (*NiceTree) IsSubmodule

func (t *NiceTree) IsSubmodule() bool

type Reference

type Reference struct {
	Name string `json:"name"`
	Hash string `json:"hash"`
}

type RepoBranchResponse

type RepoBranchResponse struct {
	Branch Branch
}

type RepoBranchesResponse

type RepoBranchesResponse struct {
	Branches []Branch `json:"branches,omitempty"`
}

type RepoCommitResponse

type RepoCommitResponse struct {
	Ref  string    `json:"ref,omitempty"`
	Diff *NiceDiff `json:"diff,omitempty"`
}

type RepoDefaultBranchResponse

type RepoDefaultBranchResponse struct {
	Branch string `json:"branch,omitempty"`
}

type RepoFormatPatchResponse

type RepoFormatPatchResponse struct {
	Rev1             string          `json:"rev1,omitempty"`
	Rev2             string          `json:"rev2,omitempty"`
	FormatPatch      []FormatPatch   `json:"format_patch,omitempty"`
	FormatPatchRaw   string          `json:"patch,omitempty"`
	CombinedPatch    []*gitdiff.File `json:"combined_patch,omitempty"`
	CombinedPatchRaw string          `json:"combined_patch_raw,omitempty"`
}

type RepoIndexResponse

type RepoIndexResponse struct {
	IsEmpty        bool            `json:"is_empty"`
	Ref            string          `json:"ref,omitempty"`
	Readme         string          `json:"readme,omitempty"`
	ReadmeFileName string          `json:"readme_file_name,omitempty"`
	Commits        []Commit        `json:"commits,omitempty"`
	Description    string          `json:"description,omitempty"`
	Files          []NiceTree      `json:"files,omitempty"`
	Branches       []Branch        `json:"branches,omitempty"`
	Tags           []*TagReference `json:"tags,omitempty"`
	TotalCommits   int             `json:"total_commits,omitempty"`
}

type RepoLanguageDetails

type RepoLanguageDetails struct {
	Name       string
	Percentage float32
	Color      string
}

type RepoLanguageResponse

type RepoLanguageResponse struct {
	// Language: File count
	Languages map[string]int64 `json:"languages"`
}

type RepoLogResponse

type RepoLogResponse struct {
	Commits     []Commit `json:"commits,omitempty"`
	Ref         string   `json:"ref,omitempty"`
	Description string   `json:"description,omitempty"`
	Log         bool     `json:"log,omitempty"`
	Total       int      `json:"total,omitempty"`
	Page        int      `json:"page,omitempty"`
	PerPage     int      `json:"per_page,omitempty"`
}

type RepoTagResponse

type RepoTagResponse struct {
	Tag *TagReference `json:"tag,omitempty"`
}

type RepoTagsResponse

type RepoTagsResponse struct {
	Tags []*TagReference `json:"tags,omitempty"`
}

type RepoTreeResponse

type RepoTreeResponse struct {
	Ref            string     `json:"ref,omitempty"`
	Parent         string     `json:"parent,omitempty"`
	Description    string     `json:"description,omitempty"`
	DotDot         string     `json:"dotdot,omitempty"`
	Files          []NiceTree `json:"files,omitempty"`
	ReadmeFileName string     `json:"readme_filename,omitempty"`
	Readme         string     `json:"readme_contents,omitempty"`
}

type SplitDiff

type SplitDiff struct {
	Name          string          `json:"name"`
	TextFragments []SplitFragment `json:"fragments"`
}

func (SplitDiff) Id

func (d SplitDiff) Id() string

type SplitFragment

type SplitFragment struct {
	Header     string      `json:"header"`
	LeftLines  []SplitLine `json:"left_lines"`
	RightLines []SplitLine `json:"right_lines"`
}

type SplitLine

type SplitLine struct {
	LineNumber int            `json:"line_number,omitempty"`
	Content    string         `json:"content"`
	Op         gitdiff.LineOp `json:"op"`
	IsEmpty    bool           `json:"is_empty"`
}

type TagReference

type TagReference struct {
	Reference
	Tag     *object.Tag `json:"tag,omitempty"`
	Message string      `json:"message,omitempty"`
}

Source Files

  • capabilities.go
  • commit.go
  • diff.go
  • diff_renderer.go
  • merge.go
  • patch.go
  • repo.go
  • split.go
  • tree.go

Jump to

Keyboard shortcuts

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