git-bug: github.com/MichaelMure/git-bug/bug Index | Examples | Files

package bug

import "github.com/MichaelMure/git-bug/bug"

Package bug contains the bug data model and low-level related functions

Index

Examples

Package Files

bug.go bug_actions.go clocks.go comment.go identity.go interface.go label.go op_add_comment.go op_create.go op_edit_comment.go op_label_change.go op_noop.go op_set_metadata.go op_set_status.go op_set_title.go operation.go operation_iterator.go operation_pack.go snapshot.go sorting.go status.go timeline.go with_snapshot.go

Variables

var ClockLoader = repository.ClockLoader{
    Clocks: []string{creationClockName, editClockName},
    Witnesser: func(repo repository.ClockedRepo) error {
        for b := range ReadAllLocalBugs(repo) {
            if b.Err != nil {
                return b.Err
            }

            createClock, err := repo.GetOrCreateClock(creationClockName)
            if err != nil {
                return err
            }
            err = createClock.Witness(b.Bug.createTime)
            if err != nil {
                return err
            }

            editClock, err := repo.GetOrCreateClock(editClockName)
            if err != nil {
                return err
            }
            err = editClock.Witness(b.Bug.editTime)
            if err != nil {
                return err
            }
        }

        return nil
    },
}

ClockLoader is the repository.ClockLoader for the Bug entity

var ErrBugNotExist = errors.New("bug doesn't exist")

func ChangeLabels Uses

func ChangeLabels(b Interface, author identity.Interface, unixTime int64, add, remove []string) ([]LabelChangeResult, *LabelChangeOperation, error)

ChangeLabels is a convenience function to apply the operation

func Create Uses

func Create(author identity.Interface, unixTime int64, title, message string) (*Bug, *CreateOperation, error)

Convenience function to apply the operation

func CreateWithFiles Uses

func CreateWithFiles(author identity.Interface, unixTime int64, title, message string, files []repository.Hash) (*Bug, *CreateOperation, error)

func Fetch Uses

func Fetch(repo repository.Repo, remote string) (string, error)

Fetch retrieve updates from a remote This does not change the local bugs state

func ListLocalIds Uses

func ListLocalIds(repo repository.Repo) ([]entity.Id, error)

ListLocalIds list all the available local bug ids

func MergeAll Uses

func MergeAll(repo repository.ClockedRepo, remote string) <-chan entity.MergeResult

MergeAll will merge all the available remote bug:

- If the remote has new commit, the local bug is updated to match the same history

(fast-forward update)

- if the local bug has new commits but the remote don't, nothing is changed - if both local and remote bug have new commits (that is, we have a concurrent edition),

new local commits are rewritten at the head of the remote history (that is, a rebase)

func NewErrMultipleMatchBug Uses

func NewErrMultipleMatchBug(matching []entity.Id) *entity.ErrMultipleMatch

func NewErrMultipleMatchOp Uses

func NewErrMultipleMatchOp(matching []entity.Id) *entity.ErrMultipleMatch

func Pull Uses

func Pull(repo repository.ClockedRepo, remote string) error

Pull will do a Fetch + MergeAll This function will return an error if a merge fail

func Push Uses

func Push(repo repository.Repo, remote string) (string, error)

Push update a remote with the local changes

func ReadAllLocalBugs Uses

func ReadAllLocalBugs(repo repository.ClockedRepo) <-chan StreamedBug

ReadAllLocalBugs read and parse all local bugs

func ReadAllRemoteBugs Uses

func ReadAllRemoteBugs(repo repository.ClockedRepo, remote string) <-chan StreamedBug

ReadAllRemoteBugs read and parse all remote bugs for a given remote

func RemoveBug Uses

func RemoveBug(repo repository.ClockedRepo, id entity.Id) error

RemoveBug will remove a local bug from its entity.Id

type AddCommentOperation Uses

type AddCommentOperation struct {
    OpBase
    Message string `json:"message"`
    // TODO: change for a map[string]util.hash to store the filename ?
    Files []repository.Hash `json:"files"`
}

AddCommentOperation will add a new comment in the bug

func AddComment Uses

func AddComment(b Interface, author identity.Interface, unixTime int64, message string) (*AddCommentOperation, error)

Convenience function to apply the operation

func AddCommentWithFiles Uses

func AddCommentWithFiles(b Interface, author identity.Interface, unixTime int64, message string, files []repository.Hash) (*AddCommentOperation, error)

func NewAddCommentOp Uses

func NewAddCommentOp(author identity.Interface, unixTime int64, message string, files []repository.Hash) *AddCommentOperation

func (*AddCommentOperation) Apply Uses

func (op *AddCommentOperation) Apply(snapshot *Snapshot)

func (*AddCommentOperation) GetFiles Uses

func (op *AddCommentOperation) GetFiles() []repository.Hash

func (*AddCommentOperation) Id Uses

func (op *AddCommentOperation) Id() entity.Id

func (*AddCommentOperation) IsAuthored Uses

func (op *AddCommentOperation) IsAuthored()

Sign post method for gqlgen

func (*AddCommentOperation) IsOperation Uses

func (op *AddCommentOperation) IsOperation()

Sign-post method for gqlgen

func (*AddCommentOperation) UnmarshalJSON Uses

func (op *AddCommentOperation) UnmarshalJSON(data []byte) error

UnmarshalJSON is a two step JSON unmarshalling This workaround is necessary to avoid the inner OpBase.MarshalJSON overriding the outer op's MarshalJSON

func (*AddCommentOperation) Validate Uses

func (op *AddCommentOperation) Validate() error

type AddCommentTimelineItem Uses

type AddCommentTimelineItem struct {
    CommentTimelineItem
}

CreateTimelineItem replace a AddComment operation in the Timeline and hold its edition history

func (*AddCommentTimelineItem) IsAuthored Uses

func (a *AddCommentTimelineItem) IsAuthored()

Sign post method for gqlgen

type Bug Uses

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

Bug hold the data of a bug thread, organized in a way close to how it will be persisted inside Git. This is the data structure used to merge two different version of the same Bug.

func FindLocalBug Uses

func FindLocalBug(repo repository.ClockedRepo, prefix string) (*Bug, error)

FindLocalBug find an existing Bug matching a prefix

func NewBug Uses

func NewBug() *Bug

NewBug create a new Bug

func ReadLocalBug Uses

func ReadLocalBug(repo repository.ClockedRepo, id entity.Id) (*Bug, error)

ReadLocalBug will read a local bug from its hash

func ReadRemoteBug Uses

func ReadRemoteBug(repo repository.ClockedRepo, remote string, id entity.Id) (*Bug, error)

ReadRemoteBug will read a remote bug from its hash

func (*Bug) Append Uses

func (bug *Bug) Append(op Operation)

Append an operation into the staging area, to be committed later

func (*Bug) Commit Uses

func (bug *Bug) Commit(repo repository.ClockedRepo) error

Commit write the staging area in Git and move the operations to the packs

func (*Bug) CommitAsNeeded Uses

func (bug *Bug) CommitAsNeeded(repo repository.ClockedRepo) error

func (*Bug) Compile Uses

func (bug *Bug) Compile() Snapshot

Compile a bug in a easily usable snapshot

func (*Bug) CreateLamportTime Uses

func (bug *Bug) CreateLamportTime() lamport.Time

CreateLamportTime return the Lamport time of creation

func (*Bug) EditLamportTime Uses

func (bug *Bug) EditLamportTime() lamport.Time

EditLamportTime return the Lamport time of the last edit

func (*Bug) EnsureIdentities Uses

func (bug *Bug) EnsureIdentities(resolver identity.Resolver) error

EnsureIdentities walk the graph of operations and make sure that all Identity are properly loaded. That is, it replace all the IdentityStub with the full Identity, loaded through a Resolver.

func (*Bug) FirstOp Uses

func (bug *Bug) FirstOp() Operation

Lookup for the very first operation of the bug. For a valid Bug, this operation should be a CreateOp

func (*Bug) Id Uses

func (bug *Bug) Id() entity.Id

Id return the Bug identifier

func (*Bug) LastOp Uses

func (bug *Bug) LastOp() Operation

Lookup for the very last operation of the bug. For a valid Bug, should never be nil

func (*Bug) Merge Uses

func (bug *Bug) Merge(repo repository.Repo, other Interface) (bool, error)

Merge a different version of the same bug by rebasing operations of this bug that are not present in the other on top of the chain of operations of the other version.

func (*Bug) NeedCommit Uses

func (bug *Bug) NeedCommit() bool

func (*Bug) Validate Uses

func (bug *Bug) Validate() error

Validate check if the Bug data is valid

type BugsByCreationTime Uses

type BugsByCreationTime []*Bug

func (BugsByCreationTime) Len Uses

func (b BugsByCreationTime) Len() int

func (BugsByCreationTime) Less Uses

func (b BugsByCreationTime) Less(i, j int) bool

func (BugsByCreationTime) Swap Uses

func (b BugsByCreationTime) Swap(i, j int)

type BugsByEditTime Uses

type BugsByEditTime []*Bug

func (BugsByEditTime) Len Uses

func (b BugsByEditTime) Len() int

func (BugsByEditTime) Less Uses

func (b BugsByEditTime) Less(i, j int) bool

func (BugsByEditTime) Swap Uses

func (b BugsByEditTime) Swap(i, j int)

type Comment Uses

type Comment struct {
    Author  identity.Interface
    Message string
    Files   []repository.Hash

    // Creation time of the comment.
    // Should be used only for human display, never for ordering as we can't rely on it in a distributed system.
    UnixTime timestamp.Timestamp
    // contains filtered or unexported fields
}

Comment represent a comment in a Bug

func (Comment) FormatTime Uses

func (c Comment) FormatTime() string

func (Comment) FormatTimeRel Uses

func (c Comment) FormatTimeRel() string

FormatTimeRel format the UnixTime of the comment for human consumption

func (Comment) Id Uses

func (c Comment) Id() entity.Id

Id return the Comment identifier

func (Comment) IsAuthored Uses

func (c Comment) IsAuthored()

Sign post method for gqlgen

type CommentHistoryStep Uses

type CommentHistoryStep struct {
    // The author of the edition, not necessarily the same as the author of the
    // original comment
    Author identity.Interface
    // The new message
    Message  string
    UnixTime timestamp.Timestamp
}

CommentHistoryStep hold one version of a message in the history

type CommentTimelineItem Uses

type CommentTimelineItem struct {
    Author    identity.Interface
    Message   string
    Files     []repository.Hash
    CreatedAt timestamp.Timestamp
    LastEdit  timestamp.Timestamp
    History   []CommentHistoryStep
    // contains filtered or unexported fields
}

CommentTimelineItem is a TimelineItem that holds a Comment and its edition history

func NewCommentTimelineItem Uses

func NewCommentTimelineItem(ID entity.Id, comment Comment) CommentTimelineItem

func (*CommentTimelineItem) Append Uses

func (c *CommentTimelineItem) Append(comment Comment)

Append will append a new comment in the history and update the other values

func (*CommentTimelineItem) Edited Uses

func (c *CommentTimelineItem) Edited() bool

Edited say if the comment was edited

func (*CommentTimelineItem) Id Uses

func (c *CommentTimelineItem) Id() entity.Id

func (*CommentTimelineItem) MessageIsEmpty Uses

func (c *CommentTimelineItem) MessageIsEmpty() bool

MessageIsEmpty return true is the message is empty or only made of spaces

type CreateOperation Uses

type CreateOperation struct {
    OpBase
    Title   string            `json:"title"`
    Message string            `json:"message"`
    Files   []repository.Hash `json:"files"`
}

CreateOperation define the initial creation of a bug

func NewCreateOp Uses

func NewCreateOp(author identity.Interface, unixTime int64, title, message string, files []repository.Hash) *CreateOperation

func (*CreateOperation) Apply Uses

func (op *CreateOperation) Apply(snapshot *Snapshot)

func (*CreateOperation) GetFiles Uses

func (op *CreateOperation) GetFiles() []repository.Hash

func (*CreateOperation) Id Uses

func (op *CreateOperation) Id() entity.Id

func (*CreateOperation) IsAuthored Uses

func (op *CreateOperation) IsAuthored()

Sign post method for gqlgen

func (*CreateOperation) IsOperation Uses

func (op *CreateOperation) IsOperation()

Sign-post method for gqlgen

func (*CreateOperation) UnmarshalJSON Uses

func (op *CreateOperation) UnmarshalJSON(data []byte) error

UnmarshalJSON is a two step JSON unmarshaling This workaround is necessary to avoid the inner OpBase.MarshalJSON overriding the outer op's MarshalJSON

func (*CreateOperation) Validate Uses

func (op *CreateOperation) Validate() error

type CreateTimelineItem Uses

type CreateTimelineItem struct {
    CommentTimelineItem
}

CreateTimelineItem replace a Create operation in the Timeline and hold its edition history

func (*CreateTimelineItem) IsAuthored Uses

func (c *CreateTimelineItem) IsAuthored()

Sign post method for gqlgen

type EditCommentOperation Uses

type EditCommentOperation struct {
    OpBase
    Target  entity.Id         `json:"target"`
    Message string            `json:"message"`
    Files   []repository.Hash `json:"files"`
}

EditCommentOperation will change a comment in the bug

func EditComment Uses

func EditComment(b Interface, author identity.Interface, unixTime int64, target entity.Id, message string) (*EditCommentOperation, error)

Convenience function to apply the operation

func EditCommentWithFiles Uses

func EditCommentWithFiles(b Interface, author identity.Interface, unixTime int64, target entity.Id, message string, files []repository.Hash) (*EditCommentOperation, error)

func EditCreateComment Uses

func EditCreateComment(b Interface, author identity.Interface, unixTime int64, message string) (*EditCommentOperation, error)

Convenience function to edit the body of a bug (the first comment)

func EditCreateCommentWithFiles Uses

func EditCreateCommentWithFiles(b Interface, author identity.Interface, unixTime int64, message string, files []repository.Hash) (*EditCommentOperation, error)

Convenience function to edit the body of a bug (the first comment)

func NewEditCommentOp Uses

func NewEditCommentOp(author identity.Interface, unixTime int64, target entity.Id, message string, files []repository.Hash) *EditCommentOperation

func (*EditCommentOperation) Apply Uses

func (op *EditCommentOperation) Apply(snapshot *Snapshot)

func (*EditCommentOperation) GetFiles Uses

func (op *EditCommentOperation) GetFiles() []repository.Hash

func (*EditCommentOperation) Id Uses

func (op *EditCommentOperation) Id() entity.Id

func (*EditCommentOperation) IsAuthored Uses

func (op *EditCommentOperation) IsAuthored()

Sign post method for gqlgen

func (*EditCommentOperation) IsOperation Uses

func (op *EditCommentOperation) IsOperation()

Sign-post method for gqlgen

func (*EditCommentOperation) UnmarshalJSON Uses

func (op *EditCommentOperation) UnmarshalJSON(data []byte) error

UnmarshalJSON is a two step JSON unmarshaling This workaround is necessary to avoid the inner OpBase.MarshalJSON overriding the outer op's MarshalJSON

func (*EditCommentOperation) Validate Uses

func (op *EditCommentOperation) Validate() error

type Interface Uses

type Interface interface {
    // Id return the Bug identifier
    Id() entity.Id

    // Validate check if the Bug data is valid
    Validate() error

    // Append an operation into the staging area, to be committed later
    Append(op Operation)

    // Indicate that the in-memory state changed and need to be commit in the repository
    NeedCommit() bool

    // Commit write the staging area in Git and move the operations to the packs
    Commit(repo repository.ClockedRepo) error

    // Merge a different version of the same bug by rebasing operations of this bug
    // that are not present in the other on top of the chain of operations of the
    // other version.
    Merge(repo repository.Repo, other Interface) (bool, error)

    // Lookup for the very first operation of the bug.
    // For a valid Bug, this operation should be a CreateOp
    FirstOp() Operation

    // Lookup for the very last operation of the bug.
    // For a valid Bug, should never be nil
    LastOp() Operation

    // Compile a bug in a easily usable snapshot
    Compile() Snapshot

    // CreateLamportTime return the Lamport time of creation
    CreateLamportTime() lamport.Time

    // EditLamportTime return the Lamport time of the last edit
    EditLamportTime() lamport.Time
}

type Label Uses

type Label string

func (Label) Color Uses

func (l Label) Color() LabelColor

RGBA from a Label computed in a deterministic way

func (Label) String Uses

func (l Label) String() string

func (Label) Validate Uses

func (l Label) Validate() error

type LabelChangeOperation Uses

type LabelChangeOperation struct {
    OpBase
    Added   []Label `json:"added"`
    Removed []Label `json:"removed"`
}

LabelChangeOperation define a Bug operation to add or remove labels

func ForceChangeLabels Uses

func ForceChangeLabels(b Interface, author identity.Interface, unixTime int64, add, remove []string) (*LabelChangeOperation, error)

ForceChangeLabels is a convenience function to apply the operation The difference with ChangeLabels is that no checks of deduplications are done. You are entirely responsible of what you are doing. In the general case, you want to use ChangeLabels instead. The intended use of this function is to allow importers to create legal but unexpected label changes, like removing a label with no information of when it was added before.

func NewLabelChangeOperation Uses

func NewLabelChangeOperation(author identity.Interface, unixTime int64, added, removed []Label) *LabelChangeOperation

func (*LabelChangeOperation) Apply Uses

func (op *LabelChangeOperation) Apply(snapshot *Snapshot)

Apply apply the operation

func (*LabelChangeOperation) Id Uses

func (op *LabelChangeOperation) Id() entity.Id

func (*LabelChangeOperation) IsAuthored Uses

func (op *LabelChangeOperation) IsAuthored()

Sign post method for gqlgen

func (*LabelChangeOperation) IsOperation Uses

func (op *LabelChangeOperation) IsOperation()

Sign-post method for gqlgen

func (*LabelChangeOperation) UnmarshalJSON Uses

func (op *LabelChangeOperation) UnmarshalJSON(data []byte) error

UnmarshalJSON is a two step JSON unmarshaling This workaround is necessary to avoid the inner OpBase.MarshalJSON overriding the outer op's MarshalJSON

func (*LabelChangeOperation) Validate Uses

func (op *LabelChangeOperation) Validate() error

type LabelChangeResult Uses

type LabelChangeResult struct {
    Label  Label
    Status LabelChangeStatus
}

func (LabelChangeResult) String Uses

func (l LabelChangeResult) String() string

type LabelChangeStatus Uses

type LabelChangeStatus int
const (
    LabelChangeAdded LabelChangeStatus
    LabelChangeRemoved
    LabelChangeDuplicateInOp
    LabelChangeAlreadySet
    LabelChangeDoesntExist
)

type LabelChangeTimelineItem Uses

type LabelChangeTimelineItem struct {
    Author   identity.Interface
    UnixTime timestamp.Timestamp
    Added    []Label
    Removed  []Label
    // contains filtered or unexported fields
}

func (LabelChangeTimelineItem) Id Uses

func (l LabelChangeTimelineItem) Id() entity.Id

func (*LabelChangeTimelineItem) IsAuthored Uses

func (l *LabelChangeTimelineItem) IsAuthored()

Sign post method for gqlgen

type LabelColor Uses

type LabelColor color.RGBA

func (LabelColor) RGBA Uses

func (lc LabelColor) RGBA() color.RGBA

func (LabelColor) Term256 Uses

func (lc LabelColor) Term256() Term256

type NoOpOperation Uses

type NoOpOperation struct {
    OpBase
}

NoOpOperation is an operation that does not change the bug state. It can however be used to store arbitrary metadata in the bug history, for example to support a bridge feature.

func NewNoOpOp Uses

func NewNoOpOp(author identity.Interface, unixTime int64) *NoOpOperation

func NoOp Uses

func NoOp(b Interface, author identity.Interface, unixTime int64, metadata map[string]string) (*NoOpOperation, error)

Convenience function to apply the operation

func (*NoOpOperation) Apply Uses

func (op *NoOpOperation) Apply(snapshot *Snapshot)

func (*NoOpOperation) Id Uses

func (op *NoOpOperation) Id() entity.Id

func (*NoOpOperation) IsAuthored Uses

func (op *NoOpOperation) IsAuthored()

Sign post method for gqlgen

func (*NoOpOperation) IsOperation Uses

func (op *NoOpOperation) IsOperation()

Sign-post method for gqlgen

func (*NoOpOperation) UnmarshalJSON Uses

func (op *NoOpOperation) UnmarshalJSON(data []byte) error

UnmarshalJSON is a two step JSON unmarshaling This workaround is necessary to avoid the inner OpBase.MarshalJSON overriding the outer op's MarshalJSON

func (*NoOpOperation) Validate Uses

func (op *NoOpOperation) Validate() error

type OpBase Uses

type OpBase struct {
    OperationType OperationType      `json:"type"`
    Author        identity.Interface `json:"author"`
    // TODO: part of the data model upgrade, this should eventually be a timestamp + lamport
    UnixTime int64             `json:"timestamp"`
    Metadata map[string]string `json:"metadata,omitempty"`
    // contains filtered or unexported fields
}

OpBase implement the common code for all operations

func (*OpBase) AllMetadata Uses

func (op *OpBase) AllMetadata() map[string]string

AllMetadata return all metadata for this operation

func (*OpBase) GetAuthor Uses

func (op *OpBase) GetAuthor() identity.Interface

GetAuthor return author identity

func (*OpBase) GetFiles Uses

func (op *OpBase) GetFiles() []repository.Hash

GetFiles return the files needed by this operation

func (*OpBase) GetMetadata Uses

func (op *OpBase) GetMetadata(key string) (string, bool)

GetMetadata retrieve arbitrary metadata about the operation

func (*OpBase) SetMetadata Uses

func (op *OpBase) SetMetadata(key string, value string)

SetMetadata store arbitrary metadata about the operation

func (*OpBase) Time Uses

func (op *OpBase) Time() time.Time

Time return the time when the operation was added

func (*OpBase) UnmarshalJSON Uses

func (op *OpBase) UnmarshalJSON(data []byte) error

type Operation Uses

type Operation interface {

    // Id return the identifier of the operation, to be used for back references
    Id() entity.Id
    // Time return the time when the operation was added
    Time() time.Time
    // GetFiles return the files needed by this operation
    GetFiles() []repository.Hash
    // Apply the operation to a Snapshot to create the final state
    Apply(snapshot *Snapshot)
    // Validate check if the operation is valid (ex: a title is a single line)
    Validate() error
    // SetMetadata store arbitrary metadata about the operation
    SetMetadata(key string, value string)
    // GetMetadata retrieve arbitrary metadata about the operation
    GetMetadata(key string) (string, bool)
    // AllMetadata return all metadata for this operation
    AllMetadata() map[string]string
    // GetAuthor return the author identity
    GetAuthor() identity.Interface

    // sign-post method for gqlgen
    IsOperation()
    // contains filtered or unexported methods
}

Operation define the interface to fulfill for an edit operation of a Bug

type OperationIterator Uses

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

Code:

b := NewBug()

// add operations

it := NewOperationIterator(b)

for it.Next() {
    // do something with each operations
    _ = it.Value()
}

func NewOperationIterator Uses

func NewOperationIterator(bug Interface) *OperationIterator

func (*OperationIterator) Next Uses

func (it *OperationIterator) Next() bool

func (*OperationIterator) Value Uses

func (it *OperationIterator) Value() Operation

type OperationPack Uses

type OperationPack struct {
    Operations []Operation
    // contains filtered or unexported fields
}

OperationPack represent an ordered set of operation to apply to a Bug. These operations are stored in a single Git commit.

These commits will be linked together in a linear chain of commits inside Git to form the complete ordered chain of operation to apply to get the final state of the Bug

func (*OperationPack) Append Uses

func (opp *OperationPack) Append(op Operation)

Append a new operation to the pack

func (*OperationPack) Clone Uses

func (opp *OperationPack) Clone() OperationPack

Make a deep copy

func (*OperationPack) IsEmpty Uses

func (opp *OperationPack) IsEmpty() bool

IsEmpty tell if the OperationPack is empty

func (*OperationPack) MarshalJSON Uses

func (opp *OperationPack) MarshalJSON() ([]byte, error)

func (*OperationPack) UnmarshalJSON Uses

func (opp *OperationPack) UnmarshalJSON(data []byte) error

func (*OperationPack) Validate Uses

func (opp *OperationPack) Validate() error

IsValid tell if the OperationPack is considered valid

func (*OperationPack) Write Uses

func (opp *OperationPack) Write(repo repository.ClockedRepo) (repository.Hash, error)

Write will serialize and store the OperationPack as a git blob and return its hash

type OperationType Uses

type OperationType int

OperationType is an operation type identifier

const (
    CreateOp OperationType
    SetTitleOp
    AddCommentOp
    SetStatusOp
    LabelChangeOp
    EditCommentOp
    NoOpOp
    SetMetadataOp
)

type SetMetadataOperation Uses

type SetMetadataOperation struct {
    OpBase
    Target      entity.Id         `json:"target"`
    NewMetadata map[string]string `json:"new_metadata"`
}

func NewSetMetadataOp Uses

func NewSetMetadataOp(author identity.Interface, unixTime int64, target entity.Id, newMetadata map[string]string) *SetMetadataOperation

func SetMetadata Uses

func SetMetadata(b Interface, author identity.Interface, unixTime int64, target entity.Id, newMetadata map[string]string) (*SetMetadataOperation, error)

Convenience function to apply the operation

func (*SetMetadataOperation) Apply Uses

func (op *SetMetadataOperation) Apply(snapshot *Snapshot)

func (*SetMetadataOperation) Id Uses

func (op *SetMetadataOperation) Id() entity.Id

func (*SetMetadataOperation) IsAuthored Uses

func (op *SetMetadataOperation) IsAuthored()

Sign post method for gqlgen

func (*SetMetadataOperation) IsOperation Uses

func (op *SetMetadataOperation) IsOperation()

Sign-post method for gqlgen

func (*SetMetadataOperation) UnmarshalJSON Uses

func (op *SetMetadataOperation) UnmarshalJSON(data []byte) error

UnmarshalJSON is a two step JSON unmarshaling This workaround is necessary to avoid the inner OpBase.MarshalJSON overriding the outer op's MarshalJSON

func (*SetMetadataOperation) Validate Uses

func (op *SetMetadataOperation) Validate() error

type SetStatusOperation Uses

type SetStatusOperation struct {
    OpBase
    Status Status `json:"status"`
}

SetStatusOperation will change the status of a bug

func Close Uses

func Close(b Interface, author identity.Interface, unixTime int64) (*SetStatusOperation, error)

Convenience function to apply the operation

func NewSetStatusOp Uses

func NewSetStatusOp(author identity.Interface, unixTime int64, status Status) *SetStatusOperation

func Open Uses

func Open(b Interface, author identity.Interface, unixTime int64) (*SetStatusOperation, error)

Convenience function to apply the operation

func (*SetStatusOperation) Apply Uses

func (op *SetStatusOperation) Apply(snapshot *Snapshot)

func (*SetStatusOperation) Id Uses

func (op *SetStatusOperation) Id() entity.Id

func (*SetStatusOperation) IsAuthored Uses

func (op *SetStatusOperation) IsAuthored()

Sign post method for gqlgen

func (*SetStatusOperation) IsOperation Uses

func (op *SetStatusOperation) IsOperation()

Sign-post method for gqlgen

func (*SetStatusOperation) UnmarshalJSON Uses

func (op *SetStatusOperation) UnmarshalJSON(data []byte) error

UnmarshalJSON is a two step JSON unmarshaling This workaround is necessary to avoid the inner OpBase.MarshalJSON overriding the outer op's MarshalJSON

func (*SetStatusOperation) Validate Uses

func (op *SetStatusOperation) Validate() error

type SetStatusTimelineItem Uses

type SetStatusTimelineItem struct {
    Author   identity.Interface
    UnixTime timestamp.Timestamp
    Status   Status
    // contains filtered or unexported fields
}

func (SetStatusTimelineItem) Id Uses

func (s SetStatusTimelineItem) Id() entity.Id

func (*SetStatusTimelineItem) IsAuthored Uses

func (s *SetStatusTimelineItem) IsAuthored()

Sign post method for gqlgen

type SetTitleOperation Uses

type SetTitleOperation struct {
    OpBase
    Title string `json:"title"`
    Was   string `json:"was"`
}

SetTitleOperation will change the title of a bug

func NewSetTitleOp Uses

func NewSetTitleOp(author identity.Interface, unixTime int64, title string, was string) *SetTitleOperation

func SetTitle Uses

func SetTitle(b Interface, author identity.Interface, unixTime int64, title string) (*SetTitleOperation, error)

Convenience function to apply the operation

func (*SetTitleOperation) Apply Uses

func (op *SetTitleOperation) Apply(snapshot *Snapshot)

func (*SetTitleOperation) Id Uses

func (op *SetTitleOperation) Id() entity.Id

func (*SetTitleOperation) IsAuthored Uses

func (op *SetTitleOperation) IsAuthored()

Sign post method for gqlgen

func (*SetTitleOperation) IsOperation Uses

func (op *SetTitleOperation) IsOperation()

Sign-post method for gqlgen

func (*SetTitleOperation) UnmarshalJSON Uses

func (op *SetTitleOperation) UnmarshalJSON(data []byte) error

UnmarshalJSON is a two step JSON unmarshaling This workaround is necessary to avoid the inner OpBase.MarshalJSON overriding the outer op's MarshalJSON

func (*SetTitleOperation) Validate Uses

func (op *SetTitleOperation) Validate() error

type SetTitleTimelineItem Uses

type SetTitleTimelineItem struct {
    Author   identity.Interface
    UnixTime timestamp.Timestamp
    Title    string
    Was      string
    // contains filtered or unexported fields
}

func (SetTitleTimelineItem) Id Uses

func (s SetTitleTimelineItem) Id() entity.Id

func (*SetTitleTimelineItem) IsAuthored Uses

func (s *SetTitleTimelineItem) IsAuthored()

Sign post method for gqlgen

type Snapshot Uses

type Snapshot struct {
    Status       Status
    Title        string
    Comments     []Comment
    Labels       []Label
    Author       identity.Interface
    Actors       []identity.Interface
    Participants []identity.Interface
    CreateTime   time.Time

    Timeline []TimelineItem

    Operations []Operation
    // contains filtered or unexported fields
}

Snapshot is a compiled form of the Bug data structure used for storage and merge

func (*Snapshot) EditTime Uses

func (snap *Snapshot) EditTime() time.Time

Return the last time a bug was modified

func (*Snapshot) GetCreateMetadata Uses

func (snap *Snapshot) GetCreateMetadata(key string) (string, bool)

GetCreateMetadata return the creation metadata

func (*Snapshot) HasActor Uses

func (snap *Snapshot) HasActor(id entity.Id) bool

HasActor return true if the id is a actor

func (*Snapshot) HasAnyActor Uses

func (snap *Snapshot) HasAnyActor(ids ...entity.Id) bool

HasAnyActor return true if one of the ids is a actor

func (*Snapshot) HasAnyParticipant Uses

func (snap *Snapshot) HasAnyParticipant(ids ...entity.Id) bool

HasAnyParticipant return true if one of the ids is a participant

func (*Snapshot) HasParticipant Uses

func (snap *Snapshot) HasParticipant(id entity.Id) bool

HasParticipant return true if the id is a participant

func (*Snapshot) Id Uses

func (snap *Snapshot) Id() entity.Id

Return the Bug identifier

func (*Snapshot) IsAuthored Uses

func (snap *Snapshot) IsAuthored()

Sign post method for gqlgen

func (*Snapshot) SearchComment Uses

func (snap *Snapshot) SearchComment(id entity.Id) (*Comment, error)

SearchComment will search for a comment matching the given hash

func (*Snapshot) SearchTimelineItem Uses

func (snap *Snapshot) SearchTimelineItem(id entity.Id) (TimelineItem, error)

SearchTimelineItem will search in the timeline for an item matching the given hash

type Status Uses

type Status int
const (
    OpenStatus Status
    ClosedStatus
)

func StatusFromString Uses

func StatusFromString(str string) (Status, error)

func (Status) Action Uses

func (s Status) Action() string

func (Status) String Uses

func (s Status) String() string

func (Status) Validate Uses

func (s Status) Validate() error

type StreamedBug Uses

type StreamedBug struct {
    Bug *Bug
    Err error
}

type Term256 Uses

type Term256 int

func (Term256) Escape Uses

func (t Term256) Escape() string

func (Term256) Unescape Uses

func (t Term256) Unescape() string

type TimelineItem Uses

type TimelineItem interface {
    // ID return the identifier of the item
    Id() entity.Id
}

type WithSnapshot Uses

type WithSnapshot struct {
    *Bug
    // contains filtered or unexported fields
}

WithSnapshot encapsulate a Bug and maintain the corresponding Snapshot efficiently

func (*WithSnapshot) Append Uses

func (b *WithSnapshot) Append(op Operation)

Append intercept Bug.Append() to update the snapshot efficiently

func (*WithSnapshot) Commit Uses

func (b *WithSnapshot) Commit(repo repository.ClockedRepo) error

Commit intercept Bug.Commit() to update the snapshot efficiently

func (*WithSnapshot) Merge Uses

func (b *WithSnapshot) Merge(repo repository.Repo, other Interface) (bool, error)

Merge intercept Bug.Merge() and clear the snapshot

func (*WithSnapshot) Snapshot Uses

func (b *WithSnapshot) Snapshot() *Snapshot

Snapshot return the current snapshot

Package bug imports 16 packages (graph) and is imported by 24 packages. Updated 2020-09-22. Refresh now. Tools for package owners.