model

package
v0.0.0-...-d3aecbb Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RepoStateActive   = RepoState("active")
	RepoStateInactive = RepoState("inactive")
	RepoStateHidden   = RepoState("hidden")
)

Variables

This section is empty.

Functions

func FindGitDir

func FindGitDir() (string, error)

func GenerateRepoNickName

func GenerateRepoNickName(directory, remote string) string

Types

type Account

type Account struct {
	UserName string `json:"username"`
	RealName string `json:"realname"`
}

type Approvals

type Approvals struct {
	Required   int       `json:"required"`
	Remaining  int       `json:"remaining"`
	ApprovedBy []Account `json:"approvedBy"`
}

type Comment

type Comment struct {
	Author      User      `json:"author"`
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedt"`
	Description string    `json:"description"`
	System      bool      `json:"system"`
	Resolvable  bool      `json:"resolvable"`
	Resolved    bool      `json:"resolved"`
	Resolver    *Account  `json:"resolver"`

	Context *CommentContext `json:"context"`
}

type CommentContext

type CommentContext struct {
	BaseHash  string `json:"baseHash"`
	StartHash string `json:"startHash"`
	HeadHash  string `json:"headHash"`
	NewFile   string `json:"newFile"`
	NewLine   uint   `json:"newLine"`
	OldFile   string `json:"oldFile"`
	OldLine   uint   `json:"oldLine"`
}

func (*CommentContext) Rebase

func (ctx *CommentContext) Rebase(target *Commit, series *Series) *CommentContext

func (*CommentContext) String

func (ctx *CommentContext) String() string

type CommentThread

type CommentThread struct {
	ID         string    `json:"id"`
	Individual bool      `json:"individual"`
	Comments   []Comment `json:"comments"`
}

type Commit

type Commit struct {
	Hash      string    `json:"hash"`
	Title     string    `json:"title"`
	Author    User      `json:"author"`
	Committer User      `json:"committer"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
	Message   string    `json:"message"`
	Diffs     []Diff    `json:"diffs"`

	Metadata CommitMetadata `json:"bichonMetadata"`
}

func (*Commit) Activity

func (commit *Commit) Activity() string

func (*Commit) Age

func (commit *Commit) Age() string

func (*Commit) GetFile

func (commit *Commit) GetFile(filename string) *Diff

type CommitMetadata

type CommitMetadata struct {
	Partial bool `json:"partial"`
}

type Diff

type Diff struct {
	Content     string `json:"content"`
	NewFile     string `json:"newFile"`
	OldFile     string `json:"oldFile"`
	NewMode     string `json:"newMode"`
	OldMode     string `json:"oldMode"`
	CreatedFile bool   `json:"createdFile"`
	RenamedFile bool   `json:"renamedFile"`
	DeletedFile bool   `json:"deletedFile"`
}

func (*Diff) Apply

func (diff *Diff) Apply(line uint) (DiffLineLocation, uint, error)

If @line is not present in diff, return (false, updated line) If @line is context in diff, return (false, updated line) If @line is deleted in diff, return (true, unchanged line) @line cannot be added in diff

func (*Diff) IsBinarySummary

func (diff *Diff) IsBinarySummary() bool

func (*Diff) Revert

func (diff *Diff) Revert(line uint) (DiffLineLocation, uint, error)

If @line is not present in diff, return (OUTSIDE, updated line) If @line is context in diff, return (CONTEXT, updated line) If @line is added in diff, return (ADDED, unchanged line) @line cannot be deleted in diff

type DiffLineLocation

type DiffLineLocation int
const (
	DIFF_LINE_LOCATION_OUTSIDE DiffLineLocation = iota
	DIFF_LINE_LOCATION_CONTEXT
	DIFF_LINE_LOCATION_ADDED
	DIFF_LINE_LOCATION_REMOVED
)

type MergeReq

type MergeReq struct {
	Repo               Repo            `json:"-"`
	ID                 uint            `json:"id"`
	Title              string          `json:"title"`
	CreatedAt          time.Time       `json:"createdAt"`
	UpdatedAt          time.Time       `json:"updatedAt"`
	Submitter          Account         `json:"submitter"`
	Assignee           *Account        `json:"assignee"`
	Reviewers          []Account       `json:"reviewers"`
	Description        string          `json:"description"`
	Versions           []Series        `json:"versions"`
	Threads            []CommentThread `json:"threads"`
	State              MergeReqState   `json:"state"`
	Labels             []string        `json:"labels"`
	UpVotes            int             `json:"upVotes"`
	DownVotes          int             `json:"downVotes"`
	MergeStatus        string          `json:"mergeStatus"`
	MergeAfterPipeline bool            `json:"mergeAfterPipeline"`
	SourceBranch       string          `json:"sourceBranch"`
	TargetBranch       string          `json:"targetBranch"`
	WIP                bool            `json:"wip"`
	Approvals          Approvals       `json:"approvals"`

	Metadata MergeReqMetadata `json:"bichonMetadata"`
}

func NewMergeReqFromJSON

func NewMergeReqFromJSON(data []byte) (*MergeReq, error)

func (*MergeReq) Activity

func (mreq *MergeReq) Activity() string

func (*MergeReq) Age

func (mreq *MergeReq) Age() string

func (*MergeReq) Equal

func (mreq *MergeReq) Equal(othermreq *MergeReq) bool

func (*MergeReq) LocalBranch

func (mreq *MergeReq) LocalBranch(version int) string

func (*MergeReq) OriginRef

func (mreq *MergeReq) OriginRef() string

func (*MergeReq) ReviewURL

func (mreq *MergeReq) ReviewURL() string

func (*MergeReq) SourceURL

func (mreq *MergeReq) SourceURL() string

func (*MergeReq) String

func (mreq *MergeReq) String() string

func (*MergeReq) ThreadIndexFromID

func (mreq *MergeReq) ThreadIndexFromID(id string) (int, error)

func (*MergeReq) ToJSON

func (mreq *MergeReq) ToJSON() ([]byte, error)

type MergeReqFilter

type MergeReqFilter func(mreq MergeReq) bool

type MergeReqList

type MergeReqList struct {
	Unfiltered []*MergeReq
	Active     []*MergeReq
	Filter     MergeReqFilter
	Sorter     MergeReqSorter
}

func (*MergeReqList) Insert

func (mreqs *MergeReqList) Insert(mreq *MergeReq)

func (*MergeReqList) Len

func (mreqs *MergeReqList) Len() int

func (*MergeReqList) Less

func (mreqs *MergeReqList) Less(i, j int) bool

func (*MergeReqList) PurgeRepo

func (mreqs *MergeReqList) PurgeRepo(repo *Repo)

func (*MergeReqList) Refresh

func (mreqs *MergeReqList) Refresh()

func (*MergeReqList) Swap

func (mreqs *MergeReqList) Swap(i, j int)

type MergeReqMetadata

type MergeReqMetadata struct {
	Partial bool           `json:"partial"`
	Status  MergeReqStatus `json:"status"`
}

type MergeReqSorter

type MergeReqSorter func(a, b MergeReq) bool

Return true if a is less than b

type MergeReqState

type MergeReqState string
const (
	STATE_OPENED MergeReqState = "opened"
	STATE_CLOSED MergeReqState = "closed"
	STATE_MERGED MergeReqState = "merged"
	STATE_LOCKED MergeReqState = "locked"
)

type MergeReqStatus

type MergeReqStatus string
const (
	STATUS_NEW     MergeReqStatus = "new"
	STATUS_UPDATED MergeReqStatus = "updated"
	STATUS_OLD     MergeReqStatus = "old"
	STATUS_READ    MergeReqStatus = "read"
)

type Repo

type Repo struct {
	NickName    string
	Directory   string
	Remote      string
	Server      string
	Project     string
	Token       string
	GlobalToken bool
	State       RepoState

	UpdatedAt *time.Time
}

func NewRepo

func NewRepo(nickname, directory, remote, server, project, token string, globalToken bool, state RepoState) *Repo

func NewRepoForDirectory

func NewRepoForDirectory(directory, remote string) (*Repo, error)

func (*Repo) Equal

func (repo *Repo) Equal(otherrepo *Repo) bool

func (*Repo) String

func (repo *Repo) String() string

type RepoState

type RepoState string

type Report

type Report struct {
	ID      string
	Name    string
	Filter  string
	Sorter  string
	Default bool
	Active  bool
}

func NewReport

func NewReport(name, filter, sorter string, def bool) Report

type Reports

type Reports []Report

func (Reports) IndexOfReport

func (r Reports) IndexOfReport(report Report) int

func (Reports) Len

func (r Reports) Len() int

func (Reports) Less

func (r Reports) Less(i, j int) bool

func (Reports) Swap

func (r Reports) Swap(i, j int)

type Repos

type Repos []Repo

func (Repos) Len

func (r Repos) Len() int

func (Repos) Less

func (r Repos) Less(i, j int) bool

func (Repos) Swap

func (r Repos) Swap(i, j int)

type Series

type Series struct {
	Index     int      `json:"index"`
	Version   int      `json:"version"`
	BaseHash  string   `json:"baseHash"`
	StartHash string   `json:"startHash"`
	HeadHash  string   `json:"headHash"`
	Patches   []Commit `json:"patches"`

	Metadata SeriesMetadata `json:"bichonMetadata"`
}

func (*Series) OriginRef

func (ser *Series) OriginRef() string

type SeriesMetadata

type SeriesMetadata struct {
	Partial bool `json:"partial"`
}

type User

type User struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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