types

package
v1.11.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: MIT Imports: 8 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 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) Id

func (d *Diff) Id() string

used by html elements as a unique ID for hrefs

func (*Diff) Split

func (d *Diff) Split() *SplitDiff

func (*Diff) Stats

func (d *Diff) Stats() DiffStat

type DiffOpts

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

type DiffStat

type DiffStat struct {
	Insertions int64
	Deletions  int64
}

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
}

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 struct {
		Message      string           `json:"message"`
		Author       object.Signature `json:"author"`
		This         string           `json:"this"`
		Parent       string           `json:"parent"`
		PGPSignature string           `json:"pgp_signature"`
		Committer    object.Signature `json:"committer"`
		Tree         string           `json:"tree"`
		ChangedId    string           `json:"change_id"`
	} `json:"commit"`
	Stat struct {
		FilesChanged int `json:"files_changed"`
		Insertions   int `json:"insertions"`
		Deletions    int `json:"deletions"`
	} `json:"stat"`
	Diff []Diff `json:"diff"`
}

A nicer git diff representation.

func (*NiceDiff) ChangedFiles

func (d *NiceDiff) ChangedFiles() []string

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 RepoBlobResponse

type RepoBlobResponse struct {
	Contents string `json:"contents,omitempty"`
	Ref      string `json:"ref,omitempty"`
	Path     string `json:"path,omitempty"`
	IsBinary bool   `json:"is_binary,omitempty"`

	Lines    int    `json:"lines,omitempty"`
	SizeHint uint64 `json:"size_hint,omitempty"`
}

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        []*object.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     []*object.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 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

used by html elements as a unique ID for hrefs

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"`
}

type TextFragment

type TextFragment struct {
	Header string         `json:"comment"`
	Lines  []gitdiff.Line `json:"lines"`
}

Source Files

  • capabilities.go
  • diff.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