review

package
v0.0.0-...-c33ec28 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change interface {
	Summary() string
}

Change is the smallest change like single comment or new commit

type Comment

type Comment struct {
	RawComment gitea.PullReviewComment
	Update     bool
}

Comment holds data about single review comment

func (*Comment) Summary

func (c *Comment) Summary() string

Summary returns a string containing the comment text, and it's an inline comment the file & line details, on a single line. Comments over 50 characters are truncated.

type GiteaCommit

type GiteaCommit struct {
	RawCommit gitea.Commit
	AuthorId  identity.Interface
	// contains filtered or unexported fields
}

GiteaCommit holds info about commit from Gitea pull request

func (*GiteaCommit) Author

func (r *GiteaCommit) Author() identity.Interface

Author returns commit author

func (*GiteaCommit) Changes

func (r *GiteaCommit) Changes() []Change

Changes returns list of a single change representing this commit

func (*GiteaCommit) Status

func (r *GiteaCommit) Status() string

Status returns "COMMIT" constant for commit

func (*GiteaCommit) Summary

func (g *GiteaCommit) Summary() string

Summary returns a string containing the commit message. Comments over 50 characters are truncated.

func (*GiteaCommit) Timestamp

func (r *GiteaCommit) Timestamp() timestamp.Timestamp

Timestamp returns commit time

func (*GiteaCommit) UnmarshalJSON

func (u *GiteaCommit) UnmarshalJSON(data []byte) error

UnmarshalJSON fulfils the Marshaler interface so that we can handle the author identity

type GiteaCommitChange

type GiteaCommitChange struct {
	RawCommit gitea.Commit
}

GiteaCommitChange is a wrapper to represent Change made by commit

func (*GiteaCommitChange) Summary

func (c *GiteaCommitChange) Summary() string

Summary returns a string containing the commit message. Comments over 50 characters are truncated.

type GiteaInfo

type GiteaInfo struct {
	Owner      string
	Repository string
	PullId     int64

	RawPull gitea.PullRequest
	Reviews []GiteaReview
	Commits []GiteaCommit
}

GiteaInfo is Gitea-specific implementation of PullRequest

func (*GiteaInfo) EnsureIdentities

func (g *GiteaInfo) EnsureIdentities(resolver identity.Resolver, found map[entity.Id]identity.Interface) error

EnsureIdentities validated if all users are resolved

func (*GiteaInfo) FetchIdentities

func (g *GiteaInfo) FetchIdentities(resolver IdentityResolver) error

FetchIdentities resolves users from pull request to git-ticket identities

func (*GiteaInfo) History

func (g *GiteaInfo) History() []TimelineEvent

History returns all events from revision sorted by time

func (*GiteaInfo) Id

func (g *GiteaInfo) Id() string

Id returns Phabricator revision id

func (*GiteaInfo) IsEmpty

func (g *GiteaInfo) IsEmpty() bool

IsEmpty check if there is any changes

func (*GiteaInfo) LatestOverallStatus

func (g *GiteaInfo) LatestOverallStatus() string

LatestOverallStatus returns the latest overall status set for this review.

func (*GiteaInfo) LatestUserStatuses

func (g *GiteaInfo) LatestUserStatuses() map[string]UserStatus

LatestUserStatuses returns a map of users and the latest status they set for this review.

func (*GiteaInfo) Merge

func (g *GiteaInfo) Merge(update PullRequest)

Merge updates state from new one

func (*GiteaInfo) Title

func (g *GiteaInfo) Title() string

Title returns Phabricator revision title

type GiteaReview

type GiteaReview struct {
	RawReview gitea.PullReview
	Comments  []Comment
	AuthorId  identity.Interface
	// contains filtered or unexported fields
}

GiteaReview holds single review event from Gitea

func (*GiteaReview) Author

func (r *GiteaReview) Author() identity.Interface

Author returns author of the change

func (*GiteaReview) Changes

func (r *GiteaReview) Changes() []Change

Changes returns list of all changes in event (e.g. all comments)

func (*GiteaReview) Status

func (r *GiteaReview) Status() string

Status returns status change by this event (possibly just comment)

func (*GiteaReview) Summary

func (g *GiteaReview) Summary() string

Summary returns a short description of the event

func (*GiteaReview) Timestamp

func (r *GiteaReview) Timestamp() timestamp.Timestamp

Timestamp returns timestamp of the event

func (*GiteaReview) UnmarshalJSON

func (u *GiteaReview) UnmarshalJSON(data []byte) error

UnmarshalJSON fulfils the Marshaler interface so that we can handle the author identity

type IdentityResolver

type IdentityResolver interface {
	ResolveIdentityPhabID(phabID string) (identity.Interface, error)
	ResolveIdentityGiteaID(giteaId int64) (identity.Interface, error)
}

IdentityResolver is subset of cache.RepoCache interface used to avoid circular dependency cache->bug->cache

type PhabReviewInfo

type PhabReviewInfo struct {
	RevisionId      string // e.g. D1234
	RevisionTitle   string `json:"Title"`
	LastTransaction string
	Updates         []ReviewUpdate
}

PhabReviewInfo is Phabricator-specific implementation of PullRequest

func (*PhabReviewInfo) EnsureIdentities

func (r *PhabReviewInfo) EnsureIdentities(resolver identity.Resolver, found map[entity.Id]identity.Interface) error

EnsureIdentities validated if all users are resolved

func (*PhabReviewInfo) FetchIdentities

func (r *PhabReviewInfo) FetchIdentities(resolver IdentityResolver) error

FetchIdentities resolves users from revision to git-ticket identities

func (*PhabReviewInfo) History

func (r *PhabReviewInfo) History() []TimelineEvent

History returns all events from revision sorted by time

func (*PhabReviewInfo) Id

func (r *PhabReviewInfo) Id() string

Id returns Phabricator revision id

func (*PhabReviewInfo) IsEmpty

func (r *PhabReviewInfo) IsEmpty() bool

IsEmpty checks is revision has any events

func (*PhabReviewInfo) LatestOverallStatus

func (r *PhabReviewInfo) LatestOverallStatus() string

LatestOverallStatus returns the latest overall status set for this review.

func (*PhabReviewInfo) LatestUserStatuses

func (r *PhabReviewInfo) LatestUserStatuses() map[string]UserStatus

LatestUserStatuses returns a map of users and the latest status they set for this review.

func (*PhabReviewInfo) Merge

func (r *PhabReviewInfo) Merge(update PullRequest)

Merge combines old state with incremental update

func (*PhabReviewInfo) Title

func (r *PhabReviewInfo) Title() string

Title returns Phabricator revision title

type PhabTransaction

type PhabTransaction struct {
	TransId   string
	PhabUser  string
	Timestamp int64

	Type TransactionType
	// comment specific fields
	Diff int    `json:",omitempty"` // diff id comment was made againt, inline comments only
	Path string `json:",omitempty"` // file path, inline comments only
	Line int    `json:",omitempty"` // line number, inline comments only
	Text string `json:",omitempty"`
	// status and userstatus specific fields
	Status string `json:",omitempty"`
	// diff specific fields
	DiffId int `json:",omitempty"`
}

PhabTransaction holds data received from Phabricator

type PhabUpdateGroup

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

PhabUpdateGroup is Phabricator-specific implementation of TimelineEvent

func (*PhabUpdateGroup) Author

func (g *PhabUpdateGroup) Author() identity.Interface

Author returns author of the event

func (*PhabUpdateGroup) Changes

func (g *PhabUpdateGroup) Changes() []Change

Changes returns list of all changes in event (e.g. all comments)

func (*PhabUpdateGroup) Summary

func (g *PhabUpdateGroup) Summary() string

Summary returns a short description of the event

func (*PhabUpdateGroup) Timestamp

func (g *PhabUpdateGroup) Timestamp() timestamp.Timestamp

Timestamp returns timestamp of the event

type PullRequest

type PullRequest interface {
	Id() string
	Title() string

	History() []TimelineEvent

	IsEmpty() bool

	EnsureIdentities(resolver identity.Resolver, found map[entity.Id]identity.Interface) error
	FetchIdentities(resolver IdentityResolver) error

	Merge(update PullRequest)

	LatestOverallStatus() string

	LatestUserStatuses() map[string]UserStatus
}

PullRequest is a generic interface for pull request or phabricator revision

func FetchGiteaReviewInfo

func FetchGiteaReviewInfo(owner string, repo string, id int64, since *GiteaInfo) (PullRequest, error)

FetchGiteaReviewInfo exports review comments and status info from Gitea for the given pull request and returns in a PullRequest object. If since review is specified only updates will be returned

func FetchPhabricatorReviewInfo

func FetchPhabricatorReviewInfo(id string, since string) (PullRequest, error)

FetchPhabricatorReviewInfo exports review comments and status info from Phabricator for the given differential ID and returns in a PullRequest object. If a since transaction ID is specified then only updates since then are returned.

type RemoveReview

type RemoveReview struct {
	ReviewId string
}

Dummy marker for removing review info

func (*RemoveReview) EnsureIdentities

func (r *RemoveReview) EnsureIdentities(identity.Resolver, map[entity.Id]identity.Interface) error

func (*RemoveReview) FetchIdentities

func (r *RemoveReview) FetchIdentities(IdentityResolver) error

func (*RemoveReview) History

func (r *RemoveReview) History() []TimelineEvent

func (*RemoveReview) Id

func (r *RemoveReview) Id() string

func (*RemoveReview) IsEmpty

func (r *RemoveReview) IsEmpty() bool

func (*RemoveReview) LatestOverallStatus

func (r *RemoveReview) LatestOverallStatus() string

func (*RemoveReview) LatestUserStatuses

func (r *RemoveReview) LatestUserStatuses() map[string]UserStatus

func (*RemoveReview) Merge

func (r *RemoveReview) Merge(PullRequest)

func (*RemoveReview) Title

func (r *RemoveReview) Title() string

type ReviewUpdate

type ReviewUpdate struct {
	PhabTransaction
	AuthorId identity.Interface `json:"Author,omitempty"`
}

ReviewUpdate extends the Phabricator data with git ticket information

func (*ReviewUpdate) Author

func (u *ReviewUpdate) Author() identity.Interface

Author returns author of the change

func (*ReviewUpdate) Status

func (u *ReviewUpdate) Status() string

Status returns status change by this event or empty string

func (*ReviewUpdate) Summary

func (c *ReviewUpdate) Summary() string

Summary returns a string containing the comment text, and it's an inline comment the file & line details, on a single line. Comments over 50 characters are truncated.

func (*ReviewUpdate) Timestamp

func (u *ReviewUpdate) Timestamp() timestamp.Timestamp

Timestamp returns timestamp of the event

func (*ReviewUpdate) UnmarshalJSON

func (u *ReviewUpdate) UnmarshalJSON(data []byte) error

UnmarshalJSON fulfils the Marshaler interface so that we can handle the author identity

type TimelineEvent

type TimelineEvent interface {
	Author() identity.Interface
	Timestamp() timestamp.Timestamp
	Changes() []Change
	Summary() string
}

TimelineEvent is interface for event happened to the PullRequest like new review, added commit or status change

type TransactionType

type TransactionType int
const (
	CommentTransaction TransactionType
	StatusTransaction
	UserStatusTransaction
	DiffTransaction
)

type UserStatus

type UserStatus interface {
	Author() identity.Interface
	Timestamp() timestamp.Timestamp
	Status() string
}

UserStatus is status change by user

Jump to

Keyboard shortcuts

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