models

package
v0.0.1-beta Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: Apache-2.0, MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = sql.ErrNoRows
View Source
var ErrRepoIDMisMatch = errors.New("repo id mismatch")

Functions

func SetupDatabase

func SetupDatabase(ctx context.Context, lc fx.Lifecycle, dbConfig *config.DatabaseConfig) (*bun.DB, error)

Types

type Blob

type Blob struct {
	bun.BaseModel `bun:"table:trees"`
	Hash          hash.Hash  `bun:"hash,pk,type:bytea"`
	RepositoryID  uuid.UUID  `bun:"repository_id,pk,type:uuid,notnull"`
	CheckSum      hash.Hash  `bun:"check_sum,type:bytea"`
	Type          ObjectType `bun:"type,notnull"`
	Size          int64      `bun:"size"`
	Properties    Property   `bun:"properties,type:jsonb,notnull"`

	CreatedAt time.Time `bun:"created_at,type:timestamp,notnull"`
	UpdatedAt time.Time `bun:"updated_at,type:timestamp,notnull"`
}

func NewBlob

func NewBlob(props Property, repoID uuid.UUID, checkSum hash.Hash, size int64) (*Blob, error)

func (*Blob) FileTree

func (blob *Blob) FileTree() *FileTree

type Branch

type Branch struct {
	bun.BaseModel `bun:"table:branches"`
	ID            uuid.UUID `bun:"id,pk,type:uuid,default:uuid_generate_v4()" json:"id"`
	// RepositoryId which repository this branch belong
	RepositoryID uuid.UUID `bun:"repository_id,type:uuid,notnull" json:"repository_id"`
	CommitHash   hash.Hash `bun:"commit_hash,type:bytea,notnull" json:"commit_hash"`
	// Path name/path of branch
	Name string `bun:"name,notnull" json:"name"`
	// Description
	Description *string `bun:"description" json:"description,omitempty"`
	// CreatorID who create this branch
	CreatorID uuid.UUID `bun:"creator_id,type:uuid,notnull" json:"creator_id"`

	CreatedAt time.Time `bun:"created_at,type:timestamp,notnull" json:"created_at"`
	UpdatedAt time.Time `bun:"updated_at,type:timestamp,notnull" json:"updated_at"`
}

type BranchRepo

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

func (BranchRepo) Delete

func (r BranchRepo) Delete(ctx context.Context, params *DeleteBranchParams) (int64, error)

func (BranchRepo) Get

func (r BranchRepo) Get(ctx context.Context, params *GetBranchParams) (*Branch, error)

func (BranchRepo) Insert

func (r BranchRepo) Insert(ctx context.Context, branch *Branch) (*Branch, error)

func (BranchRepo) List

func (r BranchRepo) List(ctx context.Context, params *ListBranchParams) ([]*Branch, bool, error)

func (BranchRepo) UpdateByID

func (r BranchRepo) UpdateByID(ctx context.Context, updateModel *UpdateBranchParams) error

type Commit

type Commit struct {
	bun.BaseModel `bun:"table:commits"`
	Hash          hash.Hash `bun:"hash,pk,type:bytea" json:"hash"`
	RepositoryID  uuid.UUID `bun:"repository_id,pk,type:uuid,notnull" json:"repository_id"`
	//////********commit********////////
	// Author is the original author of the commit.
	Author Signature `bun:"author,notnull,type:jsonb" json:"author"`
	// Committer is the one performing the commit, might be different from
	// Author.
	Committer Signature `bun:"committer,notnull,type:jsonb" json:"committer"`
	// MergeTag is the embedded tag object when a merge commit is created by
	// merging a signed tag.
	MergeTag string `bun:"merge_tag" json:"merge_tag"`
	// Message is the commit/tag message, contains arbitrary text.
	Message string `bun:"message" json:"message"`
	// TreeHash is the hash of the root tree of the commit.
	TreeHash hash.Hash `bun:"tree_hash,type:bytea,notnull" json:"tree_hash"`
	// ParentHashes are the hashes of the parent commits of the commit.
	ParentHashes []hash.Hash `bun:"parent_hashes,type:bytea[]" json:"parent_hashes"`

	CreatedAt time.Time `bun:"created_at,type:timestamp,notnull" json:"created_at"`
	UpdatedAt time.Time `bun:"updated_at,type:timestamp,notnull" json:"updated_at"`
}

func (*Commit) GetHash

func (commit *Commit) GetHash() (hash.Hash, error)

func (*Commit) NumParents

func (commit *Commit) NumParents() int

type CommitRepo

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

func (CommitRepo) Commit

func (cr CommitRepo) Commit(ctx context.Context, hash hash.Hash) (*Commit, error)

func (CommitRepo) Delete

func (cr CommitRepo) Delete(ctx context.Context, params *DeleteParams) (int64, error)

func (CommitRepo) Insert

func (cr CommitRepo) Insert(ctx context.Context, commit *Commit) (*Commit, error)

func (CommitRepo) RepositoryID

func (cr CommitRepo) RepositoryID() uuid.UUID

type CountUserParams

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

func NewCountUserParam

func NewCountUserParam() *CountUserParams

func NewCountUserParams

func NewCountUserParams() *CountUserParams

func (*CountUserParams) SetEmail

func (gup *CountUserParams) SetEmail(email string) *CountUserParams

func (*CountUserParams) SetName

func (gup *CountUserParams) SetName(name string) *CountUserParams

type DeleteBranchParams

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

func NewDeleteBranchParams

func NewDeleteBranchParams() *DeleteBranchParams

func (*DeleteBranchParams) SetID

func (*DeleteBranchParams) SetName

func (gup *DeleteBranchParams) SetName(name string) *DeleteBranchParams

func (*DeleteBranchParams) SetRepositoryID

func (gup *DeleteBranchParams) SetRepositoryID(repositoryID uuid.UUID) *DeleteBranchParams

type DeleteMergeRequestParams

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

func NewDeleteMergeRequestParams

func NewDeleteMergeRequestParams() *DeleteMergeRequestParams

func (*DeleteMergeRequestParams) SetNumber

func (dmr *DeleteMergeRequestParams) SetNumber(sequence uint64) *DeleteMergeRequestParams

func (*DeleteMergeRequestParams) SetTargetRepo

func (dmr *DeleteMergeRequestParams) SetTargetRepo(targetRepoID uuid.UUID) *DeleteMergeRequestParams

type DeleteParams

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

func NewDeleteParams

func NewDeleteParams() *DeleteParams

func (*DeleteParams) SetHash

func (params *DeleteParams) SetHash(hash hash.Hash) *DeleteParams

type DeleteRepoParams

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

func NewDeleteRepoParams

func NewDeleteRepoParams() *DeleteRepoParams

func (*DeleteRepoParams) SetID

func (drp *DeleteRepoParams) SetID(id uuid.UUID) *DeleteRepoParams

func (*DeleteRepoParams) SetName

func (drp *DeleteRepoParams) SetName(name string) *DeleteRepoParams

func (*DeleteRepoParams) SetOwnerID

func (drp *DeleteRepoParams) SetOwnerID(ownerID uuid.UUID) *DeleteRepoParams

type DeleteTreeParams

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

func NewDeleteTreeParams

func NewDeleteTreeParams() *DeleteTreeParams

func (*DeleteTreeParams) SetHash

func (dtp *DeleteTreeParams) SetHash(hash hash.Hash) *DeleteTreeParams

type DeleteWipParams

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

func NewDeleteWipParams

func NewDeleteWipParams() *DeleteWipParams

func (*DeleteWipParams) SetCreatorID

func (dwp *DeleteWipParams) SetCreatorID(creatorID uuid.UUID) *DeleteWipParams

func (*DeleteWipParams) SetID

func (dwp *DeleteWipParams) SetID(id uuid.UUID) *DeleteWipParams

func (*DeleteWipParams) SetRefID

func (dwp *DeleteWipParams) SetRefID(refID uuid.UUID) *DeleteWipParams

func (*DeleteWipParams) SetRepositoryID

func (dwp *DeleteWipParams) SetRepositoryID(repositoryID uuid.UUID) *DeleteWipParams

type FileTree

type FileTree struct {
	bun.BaseModel `bun:"table:trees"`
	Hash          hash.Hash  `bun:"hash,pk,type:bytea"`
	RepositoryID  uuid.UUID  `bun:"repository_id,pk,type:uuid,notnull"`
	CheckSum      hash.Hash  `bun:"check_sum,type:bytea"`
	Type          ObjectType `bun:"type,notnull"`
	Size          int64      `bun:"size"`
	Properties    Property   `bun:"properties,type:jsonb,notnull"`
	//tree
	SubObjects []TreeEntry `bun:"sub_objects,type:jsonb,notnull" json:"sub_objects"`

	CreatedAt time.Time `bun:"created_at,notnull" json:"created_at"`
	UpdatedAt time.Time `bun:"updated_at,notnull" json:"updated_at"`
}

func (*FileTree) Blob

func (fileTree *FileTree) Blob() *Blob

func (*FileTree) TreeNode

func (fileTree *FileTree) TreeNode() *TreeNode

type FileTreeRepo

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

func (FileTreeRepo) Blob

func (o FileTreeRepo) Blob(ctx context.Context, hash hash.Hash) (*Blob, error)

func (FileTreeRepo) Count

func (o FileTreeRepo) Count(ctx context.Context) (int, error)

func (FileTreeRepo) Delete

func (o FileTreeRepo) Delete(ctx context.Context, params *DeleteTreeParams) (int64, error)

func (FileTreeRepo) Get

func (o FileTreeRepo) Get(ctx context.Context, params *GetObjParams) (*FileTree, error)

func (FileTreeRepo) Insert

func (o FileTreeRepo) Insert(ctx context.Context, obj *FileTree) (*FileTree, error)

func (FileTreeRepo) List

func (o FileTreeRepo) List(ctx context.Context) ([]FileTree, error)

func (FileTreeRepo) RepositoryID

func (o FileTreeRepo) RepositoryID() uuid.UUID

func (FileTreeRepo) TreeNode

func (o FileTreeRepo) TreeNode(ctx context.Context, hash hash.Hash) (*TreeNode, error)

type GetBranchParams

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

func NewGetBranchParams

func NewGetBranchParams() *GetBranchParams

func (*GetBranchParams) SetID

func (gup *GetBranchParams) SetID(id uuid.UUID) *GetBranchParams

func (*GetBranchParams) SetName

func (gup *GetBranchParams) SetName(name string) *GetBranchParams

func (*GetBranchParams) SetRepositoryID

func (gup *GetBranchParams) SetRepositoryID(repositoryID uuid.UUID) *GetBranchParams

type GetMergeRequestParams

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

func NewGetMergeRequestParams

func NewGetMergeRequestParams() *GetMergeRequestParams

func (*GetMergeRequestParams) SetID

func (*GetMergeRequestParams) SetNumber

func (gmr *GetMergeRequestParams) SetNumber(sequence uint64) *GetMergeRequestParams

func (*GetMergeRequestParams) SetSourceBranch

func (gmr *GetMergeRequestParams) SetSourceBranch(sourceBranchID uuid.UUID) *GetMergeRequestParams

func (*GetMergeRequestParams) SetState

func (*GetMergeRequestParams) SetTargetBranch

func (gmr *GetMergeRequestParams) SetTargetBranch(targetBranchID uuid.UUID) *GetMergeRequestParams

func (*GetMergeRequestParams) SetTargetRepo

func (gmr *GetMergeRequestParams) SetTargetRepo(targetRepoID uuid.UUID) *GetMergeRequestParams

type GetObjParams

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

func NewGetObjParams

func NewGetObjParams() *GetObjParams

func (*GetObjParams) SetHash

func (gop *GetObjParams) SetHash(hash hash.Hash) *GetObjParams

type GetRepoParams

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

func NewGetRepoParams

func NewGetRepoParams() *GetRepoParams

func (*GetRepoParams) SetCreatorID

func (gup *GetRepoParams) SetCreatorID(creatorID uuid.UUID) *GetRepoParams

func (*GetRepoParams) SetID

func (gup *GetRepoParams) SetID(id uuid.UUID) *GetRepoParams

func (*GetRepoParams) SetName

func (gup *GetRepoParams) SetName(name string) *GetRepoParams

func (*GetRepoParams) SetOwnerID

func (gup *GetRepoParams) SetOwnerID(id uuid.UUID) *GetRepoParams

type GetUserParams

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

func NewGetUserParams

func NewGetUserParams() *GetUserParams

func (*GetUserParams) SetEmail

func (gup *GetUserParams) SetEmail(email string) *GetUserParams

func (*GetUserParams) SetID

func (gup *GetUserParams) SetID(id uuid.UUID) *GetUserParams

func (*GetUserParams) SetName

func (gup *GetUserParams) SetName(name string) *GetUserParams

type GetWipParams

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

func NewGetWipParams

func NewGetWipParams() *GetWipParams

func (*GetWipParams) SetCreatorID

func (gwp *GetWipParams) SetCreatorID(creatorID uuid.UUID) *GetWipParams

func (*GetWipParams) SetID

func (gwp *GetWipParams) SetID(id uuid.UUID) *GetWipParams

func (*GetWipParams) SetRefID

func (gwp *GetWipParams) SetRefID(refID uuid.UUID) *GetWipParams

func (*GetWipParams) SetRepositoryID

func (gwp *GetWipParams) SetRepositoryID(repositoryID uuid.UUID) *GetWipParams

type IBranchRepo

type IBranchRepo interface {
	Insert(ctx context.Context, repo *Branch) (*Branch, error)
	UpdateByID(ctx context.Context, params *UpdateBranchParams) error
	Get(ctx context.Context, id *GetBranchParams) (*Branch, error)

	List(ctx context.Context, params *ListBranchParams) ([]*Branch, bool, error)
	Delete(ctx context.Context, params *DeleteBranchParams) (int64, error)
}

func NewBranchRepo

func NewBranchRepo(db bun.IDB) IBranchRepo

type ICommitRepo

type ICommitRepo interface {
	RepositoryID() uuid.UUID
	Commit(ctx context.Context, hash hash.Hash) (*Commit, error)
	Insert(ctx context.Context, commit *Commit) (*Commit, error)
	Delete(ctx context.Context, params *DeleteParams) (int64, error)
}

func NewCommitRepo

func NewCommitRepo(db bun.IDB, repoID uuid.UUID) ICommitRepo

type IFileTreeRepo

type IFileTreeRepo interface {
	RepositoryID() uuid.UUID
	Insert(ctx context.Context, repo *FileTree) (*FileTree, error)
	Get(ctx context.Context, params *GetObjParams) (*FileTree, error)
	Count(ctx context.Context) (int, error)
	List(ctx context.Context) ([]FileTree, error)
	Blob(ctx context.Context, hash hash.Hash) (*Blob, error)
	TreeNode(ctx context.Context, hash hash.Hash) (*TreeNode, error)
	Delete(ctx context.Context, params *DeleteTreeParams) (int64, error)
}

func NewFileTree

func NewFileTree(db bun.IDB, repositoryID uuid.UUID) IFileTreeRepo

type IMergeRequestRepo

type IMergeRequestRepo interface {
	Insert(ctx context.Context, ref *MergeRequest) (*MergeRequest, error)
	Get(ctx context.Context, params *GetMergeRequestParams) (*MergeRequest, error)
	List(ctx context.Context, params *ListMergeRequestParams) ([]MergeRequest, bool, error)
	UpdateByID(ctx context.Context, params *UpdateMergeRequestParams) error
	Delete(ctx context.Context, params *DeleteMergeRequestParams) (int64, error)
}

func NewMergeRequestRepo

func NewMergeRequestRepo(db bun.IDB) IMergeRequestRepo

type IRepo

type IRepo interface {
	Transaction(ctx context.Context, fn func(repo IRepo) error, opts ...TxOption) error
	UserRepo() IUserRepo
	MergeRequestRepo() IMergeRequestRepo
	FileTreeRepo(repoID uuid.UUID) IFileTreeRepo
	CommitRepo(repoID uuid.UUID) ICommitRepo
	TagRepo(repoID uuid.UUID) ITagRepo
	BranchRepo() IBranchRepo
	RepositoryRepo() IRepositoryRepo
	WipRepo() IWipRepo
}

func NewRepo

func NewRepo(db bun.IDB) IRepo

type IRepositoryRepo

type IRepositoryRepo interface {
	Insert(ctx context.Context, repo *Repository) (*Repository, error)
	Get(ctx context.Context, params *GetRepoParams) (*Repository, error)

	List(ctx context.Context, params *ListRepoParams) ([]*Repository, bool, error)
	Delete(ctx context.Context, params *DeleteRepoParams) (int64, error)
	UpdateByID(ctx context.Context, updateModel *UpdateRepoParams) error
}

func NewRepositoryRepo

func NewRepositoryRepo(db bun.IDB) IRepositoryRepo

type ITagRepo

type ITagRepo interface {
	RepositoryID() uuid.UUID
	Insert(ctx context.Context, tag *Tag) (*Tag, error)
	Tag(ctx context.Context, hash hash.Hash) (*Tag, error)
	Delete(ctx context.Context, params *DeleteParams) (int64, error)
}

func NewTagRepo

func NewTagRepo(db bun.IDB, repID uuid.UUID) ITagRepo

type IUserRepo

type IUserRepo interface {
	Get(ctx context.Context, params *GetUserParams) (*User, error)
	Count(ctx context.Context, params *CountUserParams) (int, error)
	Insert(ctx context.Context, user *User) (*User, error)
	GetEPByName(ctx context.Context, name string) (string, error)
}

func NewUserRepo

func NewUserRepo(db bun.IDB) IUserRepo

type IWipRepo

type IWipRepo interface {
	Insert(ctx context.Context, repo *WorkingInProcess) (*WorkingInProcess, error)
	Get(ctx context.Context, params *GetWipParams) (*WorkingInProcess, error)
	List(ctx context.Context, params *ListWipParams) ([]*WorkingInProcess, error)
	Delete(ctx context.Context, params *DeleteWipParams) (int64, error)
	UpdateByID(ctx context.Context, params *UpdateWipParams) error
}

func NewWipRepo

func NewWipRepo(db bun.IDB) IWipRepo

type ListBranchParams

type ListBranchParams struct {
	RepositoryID uuid.UUID
	Name         *string
	NameMatch    MatchMode
	After        *string
	Amount       int
}

func NewListBranchParams

func NewListBranchParams() *ListBranchParams

func (*ListBranchParams) SetAfter

func (gup *ListBranchParams) SetAfter(after string) *ListBranchParams

func (*ListBranchParams) SetAmount

func (gup *ListBranchParams) SetAmount(amount int) *ListBranchParams

func (*ListBranchParams) SetName

func (gup *ListBranchParams) SetName(name string, match MatchMode) *ListBranchParams

func (*ListBranchParams) SetRepositoryID

func (gup *ListBranchParams) SetRepositoryID(repositoryID uuid.UUID) *ListBranchParams

type ListMergeRequestParams

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

func NewListMergeRequestParams

func NewListMergeRequestParams() *ListMergeRequestParams

func (*ListMergeRequestParams) SetAfter

func (*ListMergeRequestParams) SetAmount

func (lmr *ListMergeRequestParams) SetAmount(amount int) *ListMergeRequestParams

func (*ListMergeRequestParams) SetMergeState

func (lmr *ListMergeRequestParams) SetMergeState(state MergeState) *ListMergeRequestParams

func (*ListMergeRequestParams) SetTargetRepoID

func (lmr *ListMergeRequestParams) SetTargetRepoID(targetRepoID uuid.UUID) *ListMergeRequestParams

type ListRepoParams

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

func NewListRepoParams

func NewListRepoParams() *ListRepoParams

func (*ListRepoParams) SetAfter

func (lrp *ListRepoParams) SetAfter(after time.Time) *ListRepoParams

func (*ListRepoParams) SetAmount

func (lrp *ListRepoParams) SetAmount(amount int) *ListRepoParams

func (*ListRepoParams) SetCreatorID

func (lrp *ListRepoParams) SetCreatorID(creatorID uuid.UUID) *ListRepoParams

func (*ListRepoParams) SetID

func (lrp *ListRepoParams) SetID(id uuid.UUID) *ListRepoParams

func (*ListRepoParams) SetName

func (lrp *ListRepoParams) SetName(name string, match MatchMode) *ListRepoParams

func (*ListRepoParams) SetOwnerID

func (lrp *ListRepoParams) SetOwnerID(ownerID uuid.UUID) *ListRepoParams

type ListWipParams

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

func NewListWipParams

func NewListWipParams() *ListWipParams

func (*ListWipParams) SetCreatorID

func (lwp *ListWipParams) SetCreatorID(creatorID uuid.UUID) *ListWipParams

func (*ListWipParams) SetRefID

func (lwp *ListWipParams) SetRefID(refID uuid.UUID) *ListWipParams

func (*ListWipParams) SetRepositoryID

func (lwp *ListWipParams) SetRepositoryID(repositoryID uuid.UUID) *ListWipParams

type MatchMode

type MatchMode int
const (
	ExactMatch MatchMode = iota
	PrefixMatch
	SuffixMatch
	LikeMatch
)

type MergeRequest

type MergeRequest struct {
	bun.BaseModel `bun:"table:merge_requests"`
	ID            uuid.UUID `bun:"id,pk,type:uuid,default:uuid_generate_v4()" json:"id"`
	Sequence      uint64    `bun:"mr_sequence,unique:target_seq,notnull" json:"sequence"`
	SourceRepoID  uuid.UUID `bun:"source_repo_id,type:bytea,notnull" json:"source_repo_id"`
	TargetRepoID  uuid.UUID `bun:"target_repo_id,unique:target_seq,type:bytea,notnull" json:"target_repo_id"`

	TargetBranchID uuid.UUID  `bun:"target_branch_id,type:bytea,notnull" json:"target_branch_id"`
	SourceBranchID uuid.UUID  `bun:"source_branch_id,type:bytea,notnull" json:"source_branch_id"`
	Title          string     `bun:"title,notnull" json:"title"`
	MergeState     MergeState `bun:"merge_state,notnull" json:"merge_state"`
	Description    *string    `bun:"description" json:"description"`

	AuthorID uuid.UUID `bun:"author_id,type:bytea,notnull" json:"author_id"`

	CreatedAt time.Time `bun:"created_at,type:timestamp,notnull" json:"created_at"`
	UpdatedAt time.Time `bun:"updated_at,type:timestamp,notnull" json:"updated_at"`
}

type MergeRequestRepo

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

func (MergeRequestRepo) Delete

func (MergeRequestRepo) Get

func (MergeRequestRepo) Insert

func (MergeRequestRepo) List

func (MergeRequestRepo) UpdateByID

func (m MergeRequestRepo) UpdateByID(ctx context.Context, updateModel *UpdateMergeRequestParams) error

type MergeState

type MergeState int
const (
	MergeStateInit   MergeState = 1
	MergeStateMerged MergeState = 2
	MergeStateClosed MergeState = 3
)

type ObjectType

type ObjectType int8

ObjectType internal object type Integer values from 0 to 7 map to those exposed by git. AnyObject is used to represent any from 0 to 7.

const (
	InvalidObject ObjectType = 0
	CommitObject  ObjectType = 1
	TreeObject    ObjectType = 2
	BlobObject    ObjectType = 3
	TagObject     ObjectType = 4
)

type PgRepo

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

func (*PgRepo) BranchRepo

func (repo *PgRepo) BranchRepo() IBranchRepo

func (*PgRepo) CommitRepo

func (repo *PgRepo) CommitRepo(repoID uuid.UUID) ICommitRepo

func (*PgRepo) FileTreeRepo

func (repo *PgRepo) FileTreeRepo(repoID uuid.UUID) IFileTreeRepo

func (*PgRepo) MergeRequestRepo

func (repo *PgRepo) MergeRequestRepo() IMergeRequestRepo

MergeRequestRepo returns an instance of the IMergeRequestRepo interface.

It does not take any parameters. It returns an IMergeRequestRepo.

func (*PgRepo) RepositoryRepo

func (repo *PgRepo) RepositoryRepo() IRepositoryRepo

func (*PgRepo) TagRepo

func (repo *PgRepo) TagRepo(repoID uuid.UUID) ITagRepo

func (*PgRepo) Transaction

func (repo *PgRepo) Transaction(ctx context.Context, fn func(repo IRepo) error, opts ...TxOption) error

func (*PgRepo) UserRepo

func (repo *PgRepo) UserRepo() IUserRepo

func (*PgRepo) WipRepo

func (repo *PgRepo) WipRepo() IWipRepo

type Property

type Property struct {
	Mode filemode.FileMode `json:"mode"`
}

func DefaultDirProperty

func DefaultDirProperty() Property

func DefaultLeafProperty

func DefaultLeafProperty() Property

func (Property) ToMap

func (props Property) ToMap() map[string]string

type Repository

type Repository struct {
	bun.BaseModel `bun:"table:repositories" json:"bun_._base_model"`
	ID            uuid.UUID `bun:"id,pk,type:uuid,default:uuid_generate_v4()" json:"id"`
	Name          string    `bun:"name,unique:name_owner_unique,notnull" json:"name"`
	OwnerID       uuid.UUID `bun:"owner_id,unique:name_owner_unique,type:uuid,notnull" json:"owner_id"`
	HEAD          string    `bun:"head,notnull" json:"head"`

	UsePublicStorage bool    `bun:"use_public_storage,notnull" json:"use_public_storage"`
	StorageNamespace *string `bun:"storage_namespace" json:"storage_namespace,omitempty"`

	StorageAdapterParams *string `bun:"storage_adapter_params" json:"storage_adapter_params,omitempty"`

	Description *string   `bun:"description" json:"description,omitempty"`
	CreatorID   uuid.UUID `bun:"creator_id,type:uuid,notnull" json:"creator_id"`

	CreatedAt time.Time `bun:"created_at,type:timestamp,notnull" json:"created_at"`
	UpdatedAt time.Time `bun:"updated_at,type:timestamp,notnull" json:"updated_at"`
}

type RepositoryRepo

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

func (*RepositoryRepo) Delete

func (r *RepositoryRepo) Delete(ctx context.Context, params *DeleteRepoParams) (int64, error)

func (*RepositoryRepo) Get

func (r *RepositoryRepo) Get(ctx context.Context, params *GetRepoParams) (*Repository, error)

func (*RepositoryRepo) Insert

func (r *RepositoryRepo) Insert(ctx context.Context, repo *Repository) (*Repository, error)

func (*RepositoryRepo) List

func (r *RepositoryRepo) List(ctx context.Context, params *ListRepoParams) ([]*Repository, bool, error)

func (*RepositoryRepo) UpdateByID

func (r *RepositoryRepo) UpdateByID(ctx context.Context, updateModel *UpdateRepoParams) error

type Signature

type Signature struct {
	// Name represents a person name. It is an arbitrary string.
	Name string `bun:"name" json:"name"`
	// Email is an email, but it cannot be assumed to be well-formed.
	Email string `bun:"email" json:"email"`
	// When is the timestamp of the signature.
	When time.Time `bun:"when" json:"when"`
}

Signature is used to identify who and when created a commit or tag.

type Tag

type Tag struct {
	bun.BaseModel `bun:"table:tags"`
	Hash          hash.Hash  `bun:"hash,pk,type:bytea" json:"hash"`
	RepositoryID  uuid.UUID  `bun:"repository_id,pk,type:uuid,notnull" json:"repository_id"`
	Type          ObjectType `bun:"type" json:"type"`
	//////********commit********////////
	// Name of the tag.
	Name string `bun:"name" json:"name"`
	// Tagger is the one who created the tag.
	Tagger Signature `bun:"tagger,type:jsonb" json:"tagger"`
	// TargetType is the object type of the target.
	TargetType ObjectType `bun:"target_type" json:"target_type"`
	// Target is the hash of the target object.
	Target hash.Hash `bun:"target,type:bytea" json:"target"`
	// Message is the tag message, contains arbitrary text.
	Message string `bun:"message" json:"message"`

	CreatedAt time.Time `bun:"created_at,type:timestamp,notnull" json:"created_at"`
	UpdatedAt time.Time `bun:"updated_at,type:timestamp,notnull" json:"updated_at"`
}

type TagRepo

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

func (*TagRepo) Delete

func (t *TagRepo) Delete(ctx context.Context, params *DeleteParams) (int64, error)

func (*TagRepo) Insert

func (t *TagRepo) Insert(ctx context.Context, tag *Tag) (*Tag, error)

func (*TagRepo) RepositoryID

func (t *TagRepo) RepositoryID() uuid.UUID

func (*TagRepo) Tag

func (t *TagRepo) Tag(ctx context.Context, hash hash.Hash) (*Tag, error)

type TreeEntry

type TreeEntry struct {
	Name  string    `bun:"name" json:"name"`
	IsDir bool      `bun:"is_dir" json:"is_dir"`
	Hash  hash.Hash `bun:"hash" json:"hash"`
}

func NewRootTreeEntry

func NewRootTreeEntry(hash hash.Hash) TreeEntry

func SortSubObjects

func SortSubObjects(subObjects []TreeEntry) []TreeEntry

func (TreeEntry) Equal

func (treeEntry TreeEntry) Equal(other TreeEntry) bool

type TreeNode

type TreeNode struct {
	bun.BaseModel `bun:"table:trees"`
	Hash          hash.Hash `bun:"hash,pk,type:bytea" json:"hash"`
	RepositoryID  uuid.UUID `bun:"repository_id,pk,type:uuid,notnull" json:"repository_id"`

	Type       ObjectType  `bun:"type,notnull" json:"type"`
	SubObjects []TreeEntry `bun:"sub_objects,type:jsonb" json:"sub_objects"`
	Properties Property    `bun:"properties,type:jsonb,notnull" json:"properties"`

	CreatedAt time.Time `bun:"created_at,type:timestamp,notnull" json:"created_at"`
	UpdatedAt time.Time `bun:"updated_at,type:timestamp,notnull" json:"updated_at"`
}

func NewTreeNode

func NewTreeNode(props Property, repoID uuid.UUID, subObjects ...TreeEntry) (*TreeNode, error)

func (*TreeNode) FileTree

func (tn *TreeNode) FileTree() *FileTree

type TxOption

type TxOption func(*sql.TxOptions)

func IsolationLevelOption

func IsolationLevelOption(level sql.IsolationLevel) TxOption

type UpdateBranchParams

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

func NewUpdateBranchParams

func NewUpdateBranchParams(id uuid.UUID) *UpdateBranchParams

func (*UpdateBranchParams) SetCommitHash

func (up *UpdateBranchParams) SetCommitHash(commitHash hash.Hash) *UpdateBranchParams

type UpdateMergeRequestParams

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

func NewUpdateMergeRequestParams

func NewUpdateMergeRequestParams(targetRepoID uuid.UUID, sequence uint64) *UpdateMergeRequestParams

func (*UpdateMergeRequestParams) SetDescription

func (u *UpdateMergeRequestParams) SetDescription(description string) *UpdateMergeRequestParams

func (*UpdateMergeRequestParams) SetState

func (*UpdateMergeRequestParams) SetTitle

type UpdateRepoParams

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

func NewUpdateRepoParams

func NewUpdateRepoParams(id uuid.UUID) *UpdateRepoParams

func (*UpdateRepoParams) SetDescription

func (up *UpdateRepoParams) SetDescription(description string) *UpdateRepoParams

func (*UpdateRepoParams) SetHead

func (up *UpdateRepoParams) SetHead(head string) *UpdateRepoParams

type UpdateWipParams

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

func NewUpdateWipParams

func NewUpdateWipParams(id uuid.UUID) *UpdateWipParams

func (*UpdateWipParams) SetBaseCommit

func (up *UpdateWipParams) SetBaseCommit(commitHash hash.Hash) *UpdateWipParams

func (*UpdateWipParams) SetCurrentTree

func (up *UpdateWipParams) SetCurrentTree(currentTree hash.Hash) *UpdateWipParams

func (*UpdateWipParams) SetState

func (up *UpdateWipParams) SetState(state WipState) *UpdateWipParams

type User

type User struct {
	bun.BaseModel     `bun:"table:users"`
	ID                uuid.UUID `bun:"id,pk,type:uuid,default:uuid_generate_v4()" json:"id"`
	Name              string    `bun:"name,unique,notnull" json:"name"`
	Email             string    `bun:"email,unique,notnull" json:"email"`
	EncryptedPassword string    `bun:"encrypted_password,notnull" json:"encrypted_password"`
	CurrentSignInAt   time.Time `bun:"current_sign_in_at,type:timestamp" json:"current_sign_in_at"`
	LastSignInAt      time.Time `bun:"last_sign_in_at,type:timestamp" json:"last_sign_in_at"`
	CurrentSignInIP   string    `bun:"current_sign_in_ip" json:"current_sign_in_ip"`
	LastSignInIP      string    `bun:"last_sign_in_ip" json:"last_sign_in_ip"`
	CreatedAt         time.Time `bun:"created_at,type:timestamp,notnull" json:"created_at"`
	UpdatedAt         time.Time `bun:"updated_at,type:timestamp,notnull" json:"updated_at"`
}

type UserRepo

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

func (*UserRepo) Count

func (userRepo *UserRepo) Count(ctx context.Context, params *CountUserParams) (int, error)

func (*UserRepo) Get

func (userRepo *UserRepo) Get(ctx context.Context, params *GetUserParams) (*User, error)

func (*UserRepo) GetEPByName

func (userRepo *UserRepo) GetEPByName(ctx context.Context, name string) (string, error)

func (*UserRepo) Insert

func (userRepo *UserRepo) Insert(ctx context.Context, user *User) (*User, error)

type WipRepo

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

func (*WipRepo) Delete

func (s *WipRepo) Delete(ctx context.Context, params *DeleteWipParams) (int64, error)

Delete remove wip in table by id

func (*WipRepo) Get

func (s *WipRepo) Get(ctx context.Context, params *GetWipParams) (*WorkingInProcess, error)

Get wip by a group of conditions

func (*WipRepo) Insert

func (s *WipRepo) Insert(ctx context.Context, repo *WorkingInProcess) (*WorkingInProcess, error)

func (*WipRepo) List

func (s *WipRepo) List(ctx context.Context, params *ListWipParams) ([]*WorkingInProcess, error)

func (*WipRepo) UpdateByID

func (s *WipRepo) UpdateByID(ctx context.Context, updateModel *UpdateWipParams) error

type WipState

type WipState int
const (
	Init WipState = iota
	Completed
)

type WorkingInProcess

type WorkingInProcess struct {
	bun.BaseModel `bun:"table:wips"`
	ID            uuid.UUID `bun:"id,pk,type:uuid,default:uuid_generate_v4()" json:"id"`
	CurrentTree   hash.Hash `bun:"current_tree,type:bytea,notnull" json:"current_tree"`
	BaseCommit    hash.Hash `bun:"base_commit,type:bytea,notnull" json:"base_commit"`
	RepositoryID  uuid.UUID `bun:"repository_id,unique:creator_id_repository_id_ref_id_unique,type:uuid,notnull" json:"repository_id"`
	RefID         uuid.UUID `bun:"ref_id,unique:creator_id_repository_id_ref_id_unique,type:uuid,notnull" json:"ref_id"`
	State         WipState  `bun:"state,notnull" json:"state"`
	CreatorID     uuid.UUID `bun:"creator_id,unique:creator_id_repository_id_ref_id_unique,type:uuid,notnull" json:"creator_id"`
	CreatedAt     time.Time `bun:"created_at,type:timestamp,notnull" json:"created_at"`
	UpdatedAt     time.Time `bun:"updated_at,type:timestamp,notnull" json:"updated_at"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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