repo

package
v1.16.7 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: MIT Imports: 32 Imported by: 71

Documentation

Index

Constants

View Source
const (
	ArchiverGenerating = iota // the archiver is generating
	ArchiverReady             // it's ready
)

enumerate all repo archive statuses

Variables

View Source
var (
	// ErrMirrorNotExist mirror does not exist error
	ErrMirrorNotExist = errors.New("Mirror does not exist")
)
View Source
var (
	// ErrPushMirrorNotExist mirror does not exist error
	ErrPushMirrorNotExist = errors.New("PushMirror does not exist")
)

Functions

func AddRepoArchiver

func AddRepoArchiver(ctx context.Context, archiver *RepoArchiver) error

AddRepoArchiver adds an archiver

func AttachmentRelativePath

func AttachmentRelativePath(uuid string) string

AttachmentRelativePath returns the relative path

func ChangeRepositoryName

func ChangeRepositoryName(doer *user_model.User, repo *Repository, newRepoName string) (err error)

ChangeRepositoryName changes all corresponding setting from old repository name to new one.

func CheckCreateRepository

func CheckCreateRepository(doer, u *user_model.User, name string, overwriteOrAdopt bool) error

CheckCreateRepository check if could created a repository

func ComposeHTTPSCloneURL

func ComposeHTTPSCloneURL(owner, repo string) string

ComposeHTTPSCloneURL returns HTTPS clone URL based on given owner and repository name.

func CopyLanguageStat

func CopyLanguageStat(originalRepo, destRepo *Repository) error

CopyLanguageStat Copy originalRepo language stat information to destRepo (use for forked repo)

func CountOrphanedAttachments

func CountOrphanedAttachments() (int64, error)

CountOrphanedAttachments returns the number of bad attachments

func CountRepositories

func CountRepositories(private bool) int64

CountRepositories returns number of repositories. Argument private only takes effect when it is false, set it true to count all repositories.

func CountTopics

func CountTopics(opts *FindTopicOptions) (int64, error)

CountTopics counts the number of topics matching the FindTopicOptions

func CountUserRepositories

func CountUserRepositories(userID int64, private bool) int64

CountUserRepositories returns number of repositories user owns. Argument private only takes effect when it is false, set it true to count all repositories.

func DeleteAllRepoArchives

func DeleteAllRepoArchives() error

DeleteAllRepoArchives deletes all repo archives records

func DeleteAttachment

func DeleteAttachment(a *Attachment, remove bool) error

DeleteAttachment deletes the given attachment and optionally the associated file.

func DeleteAttachments

func DeleteAttachments(ctx context.Context, attachments []*Attachment, remove bool) (int, error)

DeleteAttachments deletes the given attachments and optionally the associated files.

func DeleteAttachmentsByComment

func DeleteAttachmentsByComment(commentID int64, remove bool) (int, error)

DeleteAttachmentsByComment deletes all attachments associated with the given comment.

func DeleteAttachmentsByIssue

func DeleteAttachmentsByIssue(issueID int64, remove bool) (int, error)

DeleteAttachmentsByIssue deletes all attachments associated with the given issue.

func DeleteAttachmentsByRelease

func DeleteAttachmentsByRelease(releaseID int64) error

DeleteAttachmentsByRelease deletes all attachments associated with the given release.

func DeleteMirrorByRepoID

func DeleteMirrorByRepoID(repoID int64) error

DeleteMirrorByRepoID deletes a mirror by repoID

func DeleteOrphanedAttachments

func DeleteOrphanedAttachments() error

DeleteOrphanedAttachments delete all bad attachments

func DeletePushMirrorByID

func DeletePushMirrorByID(ID int64) error

DeletePushMirrorByID deletes a push-mirrors by ID

func DeletePushMirrorsByRepoID

func DeletePushMirrorsByRepoID(repoID int64) error

DeletePushMirrorsByRepoID deletes all push-mirrors by repoID

func DeleteRedirect

func DeleteRedirect(ctx context.Context, ownerID int64, repoName string) error

DeleteRedirect delete any redirect from the specified repo name to anything else

func DeleteRepoArchiver

func DeleteRepoArchiver(ctx context.Context, archiver *RepoArchiver) error

DeleteRepoArchiver delete archiver

func ExistAttachmentsByUUID

func ExistAttachmentsByUUID(uuid string) (bool, error)

ExistAttachmentsByUUID returns true if attachment is exist by given UUID

func FindReposMapByIDs

func FindReposMapByIDs(repoIDs []int64, res map[int64]*Repository) error

FindReposMapByIDs find repos as map

func GenerateTopics

func GenerateTopics(ctx context.Context, templateRepo, generateRepo *Repository) error

GenerateTopics generates topics from a template repository

func GetPrivateRepositoryCount

func GetPrivateRepositoryCount(u *user_model.User) (int64, error)

GetPrivateRepositoryCount returns the total number of private repositories of user.

func GetPublicRepositoryCount

func GetPublicRepositoryCount(u *user_model.User) (int64, error)

GetPublicRepositoryCount returns the total number of public repositories of user.

func GetRepoWatchers

func GetRepoWatchers(repoID int64, opts db.ListOptions) ([]*user_model.User, error)

GetRepoWatchers returns range of users watching given repository.

func GetRepoWatchersIDs

func GetRepoWatchersIDs(ctx context.Context, repoID int64) ([]int64, error)

GetRepoWatchersIDs returns IDs of watchers for a given repo ID but avoids joining with `user` for performance reasons User permissions must be verified elsewhere if required

func GetRepositoriesMapByIDs

func GetRepositoriesMapByIDs(ids []int64) (map[int64]*Repository, error)

GetRepositoriesMapByIDs returns the repositories by given id slice.

func GetRepositoryCount

func GetRepositoryCount(ctx context.Context, ownerID int64) (int64, error)

GetRepositoryCount returns the total number of repositories of user.

func GetStargazers

func GetStargazers(repo *Repository, opts db.ListOptions) ([]*user_model.User, error)

GetStargazers returns the users that starred the repo.

func GetUnindexedRepos

func GetUnindexedRepos(indexerType RepoIndexerType, maxRepoID int64, page, pageSize int) ([]int64, error)

GetUnindexedRepos returns repos which do not have an indexer status

func GitConfigPath

func GitConfigPath(repoPath string) string

GitConfigPath returns the path to a repository's git config/ directory

func HasForkedRepo

func HasForkedRepo(ownerID, repoID int64) bool

HasForkedRepo checks if given user has already forked a repository with given ID.

func InsertMirror

func InsertMirror(mirror *Mirror) error

InsertMirror inserts a mirror to database

func InsertPushMirror

func InsertPushMirror(m *PushMirror) error

InsertPushMirror inserts a push-mirror to database

func IsErrAttachmentNotExist

func IsErrAttachmentNotExist(err error) bool

IsErrAttachmentNotExist checks if an error is a ErrAttachmentNotExist.

func IsErrReachLimitOfRepo

func IsErrReachLimitOfRepo(err error) bool

IsErrReachLimitOfRepo checks if an error is a ErrReachLimitOfRepo.

func IsErrRedirectNotExist

func IsErrRedirectNotExist(err error) bool

IsErrRedirectNotExist check if an error is an ErrRepoRedirectNotExist.

func IsErrRepoAlreadyExist

func IsErrRepoAlreadyExist(err error) bool

IsErrRepoAlreadyExist checks if an error is a ErrRepoAlreadyExist.

func IsErrRepoFilesAlreadyExist

func IsErrRepoFilesAlreadyExist(err error) bool

IsErrRepoFilesAlreadyExist checks if an error is a ErrRepoAlreadyExist.

func IsErrRepoNotExist

func IsErrRepoNotExist(err error) bool

IsErrRepoNotExist checks if an error is a ErrRepoNotExist.

func IsErrTopicNotExist

func IsErrTopicNotExist(err error) bool

IsErrTopicNotExist checks if an error is an ErrTopicNotExist.

func IsErrUnitTypeNotExist

func IsErrUnitTypeNotExist(err error) bool

IsErrUnitTypeNotExist checks if an error is a ErrUnitNotExist.

func IsRepositoryExist

func IsRepositoryExist(u *user_model.User, repoName string) (bool, error)

IsRepositoryExist returns true if the repository with given name under user has already existed.

func IsRepositoryExistCtx

func IsRepositoryExistCtx(ctx context.Context, u *user_model.User, repoName string) (bool, error)

IsRepositoryExistCtx returns true if the repository with given name under user has already existed.

func IsStaring

func IsStaring(userID, repoID int64) bool

IsStaring checks if user has starred given repository.

func IsUsableRepoName

func IsUsableRepoName(name string) error

IsUsableRepoName returns true when repository is usable

func IsWatchMode

func IsWatchMode(mode WatchMode) bool

IsWatchMode Decodes watchability of WatchMode

func IsWatching

func IsWatching(userID, repoID int64) bool

IsWatching checks if user has watched given repository.

func IterateAttachment

func IterateAttachment(f func(attach *Attachment) error) error

IterateAttachment iterates attachments; it should not be used when Gitea is servicing users.

func IterateRepository

func IterateRepository(f func(repo *Repository) error) error

IterateRepository iterate repositories

func LookupRedirect

func LookupRedirect(ownerID int64, repoName string) (int64, error)

LookupRedirect look up if a repository has a redirect name

func MirrorsIterate

func MirrorsIterate(f func(idx int, bean interface{}) error) error

MirrorsIterate iterates all mirror repositories.

func NewRedirect

func NewRedirect(ctx context.Context, ownerID, repoID int64, oldRepoName, newRepoName string) error

NewRedirect create a new repo redirect

func PushMirrorsIterate

func PushMirrorsIterate(f func(idx int, bean interface{}) error) error

PushMirrorsIterate iterates all push-mirror repositories.

func RemoveTopicsFromRepo

func RemoveTopicsFromRepo(ctx context.Context, repoID int64) error

RemoveTopicsFromRepo remove all topics from the repo and decrements respective topics repo count

func RepoPath

func RepoPath(userName, repoName string) string

RepoPath returns repository path by given user and repository name.

func SanitizeAndValidateTopics

func SanitizeAndValidateTopics(topics []string) (validTopics, invalidTopics []string)

SanitizeAndValidateTopics sanitizes and checks an array or topics

func SaveTopics

func SaveTopics(repoID int64, topicNames ...string) error

SaveTopics save topics to a repository

func SetArchiveRepoState

func SetArchiveRepoState(repo *Repository, isArchived bool) (err error)

SetArchiveRepoState sets if a repo is archived

func StarRepo

func StarRepo(userID, repoID int64, star bool) error

StarRepo or unstar repository.

func TouchMirror added in v1.16.6

func TouchMirror(ctx context.Context, m *Mirror) error

TouchMirror updates the mirror updatedUnix

func UpdateAttachment

func UpdateAttachment(atta *Attachment) error

UpdateAttachment updates the given attachment in database

func UpdateAttachmentByUUID

func UpdateAttachmentByUUID(ctx context.Context, attach *Attachment, cols ...string) error

UpdateAttachmentByUUID Updates attachment via uuid

func UpdateAttachmentCtx

func UpdateAttachmentCtx(ctx context.Context, atta *Attachment) error

UpdateAttachmentCtx updates the given attachment in database

func UpdateDefaultBranch

func UpdateDefaultBranch(repo *Repository) error

UpdateDefaultBranch updates the default branch

func UpdateIndexerStatus

func UpdateIndexerStatus(repo *Repository, indexerType RepoIndexerType, sha string) error

UpdateIndexerStatus updates indexer status

func UpdateLanguageStats

func UpdateLanguageStats(repo *Repository, commitID string, stats map[string]int64) error

UpdateLanguageStats updates the language statistics for repository

func UpdateMirror

func UpdateMirror(m *Mirror) error

UpdateMirror updates the mirror

func UpdatePushMirror

func UpdatePushMirror(m *PushMirror) error

UpdatePushMirror updates the push-mirror

func UpdateRepoArchiverStatus

func UpdateRepoArchiverStatus(ctx context.Context, archiver *RepoArchiver) error

UpdateRepoArchiverStatus updates archiver's status

func UpdateRepoUnit

func UpdateRepoUnit(unit *RepoUnit) error

UpdateRepoUnit updates the provided repo unit

func UpdateRepositoryCols

func UpdateRepositoryCols(repo *Repository, cols ...string) error

UpdateRepositoryCols updates repository's columns

func UpdateRepositoryColsCtx

func UpdateRepositoryColsCtx(ctx context.Context, repo *Repository, cols ...string) error

UpdateRepositoryColsCtx updates repository's columns

func UpdateRepositoryOwnerNames

func UpdateRepositoryOwnerNames(ownerID int64, ownerName string) error

UpdateRepositoryOwnerNames updates repository owner_names (this should only be used when the ownerName has changed case)

func UpdateRepositoryUnits

func UpdateRepositoryUnits(repo *Repository, units []RepoUnit, deleteUnitTypes []unit.Type) (err error)

UpdateRepositoryUnits updates a repository's units

func UpdateRepositoryUpdatedTime

func UpdateRepositoryUpdatedTime(repoID int64, updateTime time.Time) error

UpdateRepositoryUpdatedTime updates a repository's updated time

func ValidateTopic

func ValidateTopic(topic string) bool

ValidateTopic checks a topic by length and match pattern rules

func WatchIfAuto

func WatchIfAuto(userID, repoID int64, isWrite bool) error

WatchIfAuto subscribes to repo if AutoWatchOnChanges is set

func WatchRepo

func WatchRepo(userID, repoID int64, watch bool) (err error)

WatchRepo watch or unwatch repository.

func WatchRepoCtx

func WatchRepoCtx(ctx context.Context, userID, repoID int64, doWatch bool) (err error)

WatchRepoCtx watch or unwatch repository.

func WatchRepoMode

func WatchRepoMode(userID, repoID int64, mode WatchMode) (err error)

WatchRepoMode watch repository in specific mode.

func WikiPath

func WikiPath(userName, repoName string) string

WikiPath returns wiki data path by given user and repository name.

Types

type ArchiverStatus

type ArchiverStatus int

ArchiverStatus represents repo archive status

type Attachment

type Attachment struct {
	ID            int64  `xorm:"pk autoincr"`
	UUID          string `xorm:"uuid UNIQUE"`
	RepoID        int64  `xorm:"INDEX"`           // this should not be zero
	IssueID       int64  `xorm:"INDEX"`           // maybe zero when creating
	ReleaseID     int64  `xorm:"INDEX"`           // maybe zero when creating
	UploaderID    int64  `xorm:"INDEX DEFAULT 0"` // Notice: will be zero before this column added
	CommentID     int64
	Name          string
	DownloadCount int64              `xorm:"DEFAULT 0"`
	Size          int64              `xorm:"DEFAULT 0"`
	CreatedUnix   timeutil.TimeStamp `xorm:"created"`
}

Attachment represent a attachment of issue/comment/release.

func GetAttachmentByID

func GetAttachmentByID(id int64) (*Attachment, error)

GetAttachmentByID returns attachment by given id

func GetAttachmentByReleaseIDFileName

func GetAttachmentByReleaseIDFileName(releaseID int64, fileName string) (*Attachment, error)

GetAttachmentByReleaseIDFileName returns attachment by given releaseId and fileName.

func GetAttachmentByUUID

func GetAttachmentByUUID(uuid string) (*Attachment, error)

GetAttachmentByUUID returns attachment by given UUID.

func GetAttachmentsByCommentID

func GetAttachmentsByCommentID(commentID int64) ([]*Attachment, error)

GetAttachmentsByCommentID returns all attachments if comment by given ID.

func GetAttachmentsByCommentIDCtx

func GetAttachmentsByCommentIDCtx(ctx context.Context, commentID int64) ([]*Attachment, error)

GetAttachmentsByCommentIDCtx returns all attachments if comment by given ID.

func GetAttachmentsByIssueID

func GetAttachmentsByIssueID(issueID int64) ([]*Attachment, error)

GetAttachmentsByIssueID returns all attachments of an issue.

func GetAttachmentsByIssueIDCtx

func GetAttachmentsByIssueIDCtx(ctx context.Context, issueID int64) ([]*Attachment, error)

GetAttachmentsByIssueIDCtx returns all attachments of an issue.

func GetAttachmentsByUUIDs

func GetAttachmentsByUUIDs(ctx context.Context, uuids []string) ([]*Attachment, error)

GetAttachmentsByUUIDs returns attachment by given UUID list.

func (*Attachment) DownloadURL

func (a *Attachment) DownloadURL() string

DownloadURL returns the download url of the attached file

func (*Attachment) IncreaseDownloadCount

func (a *Attachment) IncreaseDownloadCount() error

IncreaseDownloadCount is update download count + 1

func (*Attachment) RelativePath

func (a *Attachment) RelativePath() string

RelativePath returns the relative path of the attachment

type CloneLink struct {
	SSH   string
	HTTPS string
	Git   string
}

CloneLink represents different types of clone URLs of repository.

type ErrAttachmentNotExist

type ErrAttachmentNotExist struct {
	ID   int64
	UUID string
}

ErrAttachmentNotExist represents a "AttachmentNotExist" kind of error.

func (ErrAttachmentNotExist) Error

func (err ErrAttachmentNotExist) Error() string

type ErrReachLimitOfRepo

type ErrReachLimitOfRepo struct {
	Limit int
}

ErrReachLimitOfRepo represents a "ReachLimitOfRepo" kind of error.

func (ErrReachLimitOfRepo) Error

func (err ErrReachLimitOfRepo) Error() string

type ErrRedirectNotExist

type ErrRedirectNotExist struct {
	OwnerID  int64
	RepoName string
}

ErrRedirectNotExist represents a "RedirectNotExist" kind of error.

func (ErrRedirectNotExist) Error

func (err ErrRedirectNotExist) Error() string

type ErrRepoAlreadyExist

type ErrRepoAlreadyExist struct {
	Uname string
	Name  string
}

ErrRepoAlreadyExist represents a "RepoAlreadyExist" kind of error.

func (ErrRepoAlreadyExist) Error

func (err ErrRepoAlreadyExist) Error() string

type ErrRepoFilesAlreadyExist

type ErrRepoFilesAlreadyExist struct {
	Uname string
	Name  string
}

ErrRepoFilesAlreadyExist represents a "RepoFilesAlreadyExist" kind of error.

func (ErrRepoFilesAlreadyExist) Error

func (err ErrRepoFilesAlreadyExist) Error() string

type ErrRepoNotExist

type ErrRepoNotExist struct {
	ID        int64
	UID       int64
	OwnerName string
	Name      string
}

ErrRepoNotExist represents a "RepoNotExist" kind of error.

func (ErrRepoNotExist) Error

func (err ErrRepoNotExist) Error() string

type ErrTopicNotExist

type ErrTopicNotExist struct {
	Name string
}

ErrTopicNotExist represents an error that a topic is not exist

func (ErrTopicNotExist) Error

func (err ErrTopicNotExist) Error() string

Error implements error interface

type ErrUnitTypeNotExist

type ErrUnitTypeNotExist struct {
	UT unit.Type
}

ErrUnitTypeNotExist represents a "UnitTypeNotExist" kind of error.

func (ErrUnitTypeNotExist) Error

func (err ErrUnitTypeNotExist) Error() string

type ExternalTrackerConfig

type ExternalTrackerConfig struct {
	ExternalTrackerURL    string
	ExternalTrackerFormat string
	ExternalTrackerStyle  string
}

ExternalTrackerConfig describes external tracker config

func (*ExternalTrackerConfig) FromDB

func (cfg *ExternalTrackerConfig) FromDB(bs []byte) error

FromDB fills up a ExternalTrackerConfig from serialized format.

func (*ExternalTrackerConfig) ToDB

func (cfg *ExternalTrackerConfig) ToDB() ([]byte, error)

ToDB exports a ExternalTrackerConfig to a serialized format.

type ExternalWikiConfig

type ExternalWikiConfig struct {
	ExternalWikiURL string
}

ExternalWikiConfig describes external wiki config

func (*ExternalWikiConfig) FromDB

func (cfg *ExternalWikiConfig) FromDB(bs []byte) error

FromDB fills up a ExternalWikiConfig from serialized format.

func (*ExternalWikiConfig) ToDB

func (cfg *ExternalWikiConfig) ToDB() ([]byte, error)

ToDB exports a ExternalWikiConfig to a serialized format.

type FindRepoArchiversOption

type FindRepoArchiversOption struct {
	db.ListOptions
	OlderThan time.Duration
}

FindRepoArchiversOption represents an archiver options

type FindTopicOptions

type FindTopicOptions struct {
	db.ListOptions
	RepoID  int64
	Keyword string
}

FindTopicOptions represents the options when fdin topics

type IssuesConfig

type IssuesConfig struct {
	EnableTimetracker                bool
	AllowOnlyContributorsToTrackTime bool
	EnableDependencies               bool
}

IssuesConfig describes issues config

func (*IssuesConfig) FromDB

func (cfg *IssuesConfig) FromDB(bs []byte) error

FromDB fills up a IssuesConfig from serialized format.

func (*IssuesConfig) ToDB

func (cfg *IssuesConfig) ToDB() ([]byte, error)

ToDB exports a IssuesConfig to a serialized format.

type LanguageStat

type LanguageStat struct {
	ID          int64 `xorm:"pk autoincr"`
	RepoID      int64 `xorm:"UNIQUE(s) INDEX NOT NULL"`
	CommitID    string
	IsPrimary   bool
	Language    string             `xorm:"VARCHAR(50) UNIQUE(s) INDEX NOT NULL"`
	Percentage  float32            `xorm:"-"`
	Size        int64              `xorm:"NOT NULL DEFAULT 0"`
	Color       string             `xorm:"-"`
	CreatedUnix timeutil.TimeStamp `xorm:"INDEX CREATED"`
}

LanguageStat describes language statistics of a repository

type LanguageStatList

type LanguageStatList []*LanguageStat

LanguageStatList defines a list of language statistics

func GetLanguageStats

func GetLanguageStats(repo *Repository) (LanguageStatList, error)

GetLanguageStats returns the language statistics for a repository

func GetTopLanguageStats

func GetTopLanguageStats(repo *Repository, limit int) (LanguageStatList, error)

GetTopLanguageStats returns the top language statistics for a repository

func (LanguageStatList) LoadAttributes

func (stats LanguageStatList) LoadAttributes()

LoadAttributes loads attributes

type MergeStyle

type MergeStyle string

MergeStyle represents the approach to merge commits into base branch.

const (
	// MergeStyleMerge create merge commit
	MergeStyleMerge MergeStyle = "merge"
	// MergeStyleRebase rebase before merging
	MergeStyleRebase MergeStyle = "rebase"
	// MergeStyleRebaseMerge rebase before merging with merge commit (--no-ff)
	MergeStyleRebaseMerge MergeStyle = "rebase-merge"
	// MergeStyleSquash squash commits into single commit before merging
	MergeStyleSquash MergeStyle = "squash"
	// MergeStyleManuallyMerged pr has been merged manually, just mark it as merged directly
	MergeStyleManuallyMerged MergeStyle = "manually-merged"
	// MergeStyleRebaseUpdate not a merge style, used to update pull head by rebase
	MergeStyleRebaseUpdate MergeStyle = "rebase-update-only"
)

type Mirror

type Mirror struct {
	ID          int64       `xorm:"pk autoincr"`
	RepoID      int64       `xorm:"INDEX"`
	Repo        *Repository `xorm:"-"`
	Interval    time.Duration
	EnablePrune bool `xorm:"NOT NULL DEFAULT true"`

	UpdatedUnix    timeutil.TimeStamp `xorm:"INDEX"`
	NextUpdateUnix timeutil.TimeStamp `xorm:"INDEX"`

	LFS         bool   `xorm:"lfs_enabled NOT NULL DEFAULT false"`
	LFSEndpoint string `xorm:"lfs_endpoint TEXT"`

	Address string `xorm:"-"`
}

Mirror represents mirror information of a repository.

func GetMirrorByRepoID

func GetMirrorByRepoID(repoID int64) (*Mirror, error)

GetMirrorByRepoID returns mirror information of a repository.

func (*Mirror) AfterLoad

func (m *Mirror) AfterLoad(session *xorm.Session)

AfterLoad is invoked from XORM after setting the values of all fields of this object.

func (*Mirror) BeforeInsert

func (m *Mirror) BeforeInsert()

BeforeInsert will be invoked by XORM before inserting a record

func (*Mirror) GetRemoteName

func (m *Mirror) GetRemoteName() string

GetRemoteName returns the name of the remote.

func (*Mirror) GetRepository

func (m *Mirror) GetRepository() *Repository

GetRepository returns the repository.

func (*Mirror) ScheduleNextUpdate

func (m *Mirror) ScheduleNextUpdate()

ScheduleNextUpdate calculates and sets next update time.

type MirrorRepositoryList

type MirrorRepositoryList []*Repository

MirrorRepositoryList contains the mirror repositories

func (MirrorRepositoryList) LoadAttributes

func (repos MirrorRepositoryList) LoadAttributes() error

LoadAttributes loads the attributes for the given MirrorRepositoryList

type PullRequestsConfig

type PullRequestsConfig struct {
	IgnoreWhitespaceConflicts     bool
	AllowMerge                    bool
	AllowRebase                   bool
	AllowRebaseMerge              bool
	AllowSquash                   bool
	AllowManualMerge              bool
	AutodetectManualMerge         bool
	DefaultDeleteBranchAfterMerge bool
	DefaultMergeStyle             MergeStyle
}

PullRequestsConfig describes pull requests config

func (*PullRequestsConfig) AllowedMergeStyleCount

func (cfg *PullRequestsConfig) AllowedMergeStyleCount() int

AllowedMergeStyleCount returns the total count of allowed merge styles for the PullRequestsConfig

func (*PullRequestsConfig) FromDB

func (cfg *PullRequestsConfig) FromDB(bs []byte) error

FromDB fills up a PullRequestsConfig from serialized format.

func (*PullRequestsConfig) GetDefaultMergeStyle

func (cfg *PullRequestsConfig) GetDefaultMergeStyle() MergeStyle

GetDefaultMergeStyle returns the default merge style for this pull request

func (*PullRequestsConfig) IsMergeStyleAllowed

func (cfg *PullRequestsConfig) IsMergeStyleAllowed(mergeStyle MergeStyle) bool

IsMergeStyleAllowed returns if merge style is allowed

func (*PullRequestsConfig) ToDB

func (cfg *PullRequestsConfig) ToDB() ([]byte, error)

ToDB exports a PullRequestsConfig to a serialized format.

type PushMirror

type PushMirror struct {
	ID         int64       `xorm:"pk autoincr"`
	RepoID     int64       `xorm:"INDEX"`
	Repo       *Repository `xorm:"-"`
	RemoteName string

	Interval       time.Duration
	CreatedUnix    timeutil.TimeStamp `xorm:"created"`
	LastUpdateUnix timeutil.TimeStamp `xorm:"INDEX last_update"`
	LastError      string             `xorm:"text"`
}

PushMirror represents mirror information of a repository.

func GetPushMirrorByID

func GetPushMirrorByID(ID int64) (*PushMirror, error)

GetPushMirrorByID returns push-mirror information.

func GetPushMirrorsByRepoID

func GetPushMirrorsByRepoID(repoID int64) ([]*PushMirror, error)

GetPushMirrorsByRepoID returns push-mirror information of a repository.

func (*PushMirror) AfterLoad

func (m *PushMirror) AfterLoad(session *xorm.Session)

AfterLoad is invoked from XORM after setting the values of all fields of this object.

func (*PushMirror) GetRemoteName

func (m *PushMirror) GetRemoteName() string

GetRemoteName returns the name of the remote.

func (*PushMirror) GetRepository

func (m *PushMirror) GetRepository() *Repository

GetRepository returns the path of the repository.

type Redirect

type Redirect struct {
	ID             int64  `xorm:"pk autoincr"`
	OwnerID        int64  `xorm:"UNIQUE(s)"`
	LowerName      string `xorm:"UNIQUE(s) INDEX NOT NULL"`
	RedirectRepoID int64  // repoID to redirect to
}

Redirect represents that a repo name should be redirected to another

func (Redirect) TableName

func (Redirect) TableName() string

TableName represents real table name in database

type RemoteMirrorer

type RemoteMirrorer interface {
	GetRepository() *Repository
	GetRemoteName() string
}

RemoteMirrorer defines base methods for pull/push mirrors.

type RepoArchiver

type RepoArchiver struct {
	ID          int64           `xorm:"pk autoincr"`
	RepoID      int64           `xorm:"index unique(s)"`
	Type        git.ArchiveType `xorm:"unique(s)"`
	Status      ArchiverStatus
	CommitID    string             `xorm:"VARCHAR(40) unique(s)"`
	CreatedUnix timeutil.TimeStamp `xorm:"INDEX NOT NULL created"`
}

RepoArchiver represents all archivers

func FindRepoArchives

func FindRepoArchives(opts FindRepoArchiversOption) ([]*RepoArchiver, error)

FindRepoArchives find repo archivers

func GetRepoArchiver

func GetRepoArchiver(ctx context.Context, repoID int64, tp git.ArchiveType, commitID string) (*RepoArchiver, error)

GetRepoArchiver get an archiver

func (*RepoArchiver) RelativePath

func (archiver *RepoArchiver) RelativePath() (string, error)

RelativePath returns relative path

type RepoIndexerStatus

type RepoIndexerStatus struct {
	ID          int64           `xorm:"pk autoincr"`
	RepoID      int64           `xorm:"INDEX(s)"`
	CommitSha   string          `xorm:"VARCHAR(40)"`
	IndexerType RepoIndexerType `xorm:"INDEX(s) NOT NULL DEFAULT 0"`
}

RepoIndexerStatus status of a repo's entry in the repo indexer For now, implicitly refers to default branch

func GetIndexerStatus

func GetIndexerStatus(repo *Repository, indexerType RepoIndexerType) (*RepoIndexerStatus, error)

GetIndexerStatus loads repo codes indxer status

type RepoIndexerType

type RepoIndexerType int //revive:disable-line:exported

RepoIndexerType specifies the repository indexer type

const (
	// RepoIndexerTypeCode code indexer
	RepoIndexerTypeCode RepoIndexerType = iota // 0
	// RepoIndexerTypeStats repository stats indexer
	RepoIndexerTypeStats // 1
)

type RepoTopic

type RepoTopic struct {
	RepoID  int64 `xorm:"pk"`
	TopicID int64 `xorm:"pk"`
}

RepoTopic represents associated repositories and topics

type RepoUnit

type RepoUnit struct {
	ID          int64
	RepoID      int64              `xorm:"INDEX(s)"`
	Type        unit.Type          `xorm:"INDEX(s)"`
	Config      convert.Conversion `xorm:"TEXT"`
	CreatedUnix timeutil.TimeStamp `xorm:"INDEX CREATED"`
}

RepoUnit describes all units of a repository

func (*RepoUnit) BeforeSet

func (r *RepoUnit) BeforeSet(colName string, val xorm.Cell)

BeforeSet is invoked from XORM before setting the value of a field of this object.

func (*RepoUnit) CodeConfig

func (r *RepoUnit) CodeConfig() *UnitConfig

CodeConfig returns config for unit.TypeCode

func (*RepoUnit) ExternalTrackerConfig

func (r *RepoUnit) ExternalTrackerConfig() *ExternalTrackerConfig

ExternalTrackerConfig returns config for unit.TypeExternalTracker

func (*RepoUnit) ExternalWikiConfig

func (r *RepoUnit) ExternalWikiConfig() *ExternalWikiConfig

ExternalWikiConfig returns config for unit.TypeExternalWiki

func (*RepoUnit) IssuesConfig

func (r *RepoUnit) IssuesConfig() *IssuesConfig

IssuesConfig returns config for unit.TypeIssues

func (*RepoUnit) PullRequestsConfig

func (r *RepoUnit) PullRequestsConfig() *PullRequestsConfig

PullRequestsConfig returns config for unit.TypePullRequests

func (*RepoUnit) ReleasesConfig

func (r *RepoUnit) ReleasesConfig() *UnitConfig

ReleasesConfig returns config for unit.TypeReleases

func (*RepoUnit) Unit

func (r *RepoUnit) Unit() unit.Unit

Unit returns Unit

type Repository

type Repository struct {
	ID                  int64 `xorm:"pk autoincr"`
	OwnerID             int64 `xorm:"UNIQUE(s) index"`
	OwnerName           string
	Owner               *user_model.User   `xorm:"-"`
	LowerName           string             `xorm:"UNIQUE(s) INDEX NOT NULL"`
	Name                string             `xorm:"INDEX NOT NULL"`
	Description         string             `xorm:"TEXT"`
	Website             string             `xorm:"VARCHAR(2048)"`
	OriginalServiceType api.GitServiceType `xorm:"index"`
	OriginalURL         string             `xorm:"VARCHAR(2048)"`
	DefaultBranch       string

	NumWatches          int
	NumStars            int
	NumForks            int
	NumIssues           int
	NumClosedIssues     int
	NumOpenIssues       int `xorm:"-"`
	NumPulls            int
	NumClosedPulls      int
	NumOpenPulls        int `xorm:"-"`
	NumMilestones       int `xorm:"NOT NULL DEFAULT 0"`
	NumClosedMilestones int `xorm:"NOT NULL DEFAULT 0"`
	NumOpenMilestones   int `xorm:"-"`
	NumProjects         int `xorm:"NOT NULL DEFAULT 0"`
	NumClosedProjects   int `xorm:"NOT NULL DEFAULT 0"`
	NumOpenProjects     int `xorm:"-"`

	IsPrivate  bool `xorm:"INDEX"`
	IsEmpty    bool `xorm:"INDEX"`
	IsArchived bool `xorm:"INDEX"`
	IsMirror   bool `xorm:"INDEX"`
	*Mirror    `xorm:"-"`
	Status     RepositoryStatus `xorm:"NOT NULL DEFAULT 0"`

	RenderingMetas         map[string]string `xorm:"-"`
	DocumentRenderingMetas map[string]string `xorm:"-"`
	Units                  []*RepoUnit       `xorm:"-"`
	PrimaryLanguage        *LanguageStat     `xorm:"-"`

	IsFork                          bool               `xorm:"INDEX NOT NULL DEFAULT false"`
	ForkID                          int64              `xorm:"INDEX"`
	BaseRepo                        *Repository        `xorm:"-"`
	IsTemplate                      bool               `xorm:"INDEX NOT NULL DEFAULT false"`
	TemplateID                      int64              `xorm:"INDEX"`
	Size                            int64              `xorm:"NOT NULL DEFAULT 0"`
	CodeIndexerStatus               *RepoIndexerStatus `xorm:"-"`
	StatsIndexerStatus              *RepoIndexerStatus `xorm:"-"`
	IsFsckEnabled                   bool               `xorm:"NOT NULL DEFAULT true"`
	CloseIssuesViaCommitInAnyBranch bool               `xorm:"NOT NULL DEFAULT false"`
	Topics                          []string           `xorm:"TEXT JSON"`

	TrustModel TrustModelType

	// Avatar: ID(10-20)-md5(32) - must fit into 64 symbols
	Avatar string `xorm:"VARCHAR(64)"`

	CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
}

Repository represents a git repository.

func GetForkedRepo

func GetForkedRepo(ownerID, repoID int64) *Repository

GetForkedRepo checks if given user has already forked a repository with given ID.

func GetForks

func GetForks(repo *Repository, listOptions db.ListOptions) ([]*Repository, error)

GetForks returns all the forks of the repository

func GetRepositoriesByForkID

func GetRepositoriesByForkID(ctx context.Context, forkID int64) ([]*Repository, error)

GetRepositoriesByForkID returns all repositories with given fork ID.

func GetRepositoryByID

func GetRepositoryByID(id int64) (*Repository, error)

GetRepositoryByID returns the repository by given id if exists.

func GetRepositoryByIDCtx

func GetRepositoryByIDCtx(ctx context.Context, id int64) (*Repository, error)

GetRepositoryByIDCtx returns the repository by given id if exists.

func GetRepositoryByName

func GetRepositoryByName(ownerID int64, name string) (*Repository, error)

GetRepositoryByName returns the repository by given name under user if exists.

func GetRepositoryByOwnerAndName

func GetRepositoryByOwnerAndName(ownerName, repoName string) (*Repository, error)

GetRepositoryByOwnerAndName returns the repository by given ownername and reponame.

func GetRepositoryByOwnerAndNameCtx

func GetRepositoryByOwnerAndNameCtx(ctx context.Context, ownerName, repoName string) (*Repository, error)

GetRepositoryByOwnerAndNameCtx returns the repository by given owner name and repo name

func GetTemplateRepo

func GetTemplateRepo(repo *Repository) (*Repository, error)

GetTemplateRepo populates repo.TemplateRepo for a generated repository and returns an error on failure (NOTE: no error is returned for non-generated repositories, and TemplateRepo will be left untouched)

func GetUserFork

func GetUserFork(repoID, userID int64) (*Repository, error)

GetUserFork return user forked repository from this repository, if not forked return nil

func GetUserMirrorRepositories

func GetUserMirrorRepositories(userID int64) ([]*Repository, error)

GetUserMirrorRepositories returns a list of mirror repositories of given user.

func (*Repository) APIURL

func (repo *Repository) APIURL() string

APIURL returns the repository API URL

func (*Repository) AfterLoad

func (repo *Repository) AfterLoad()

AfterLoad is invoked from XORM after setting the values of all fields of this object.

func (*Repository) AllowOnlyContributorsToTrackTime

func (repo *Repository) AllowOnlyContributorsToTrackTime() bool

AllowOnlyContributorsToTrackTime returns value of IssuesConfig or the default value

func (*Repository) AllowsPulls

func (repo *Repository) AllowsPulls() bool

AllowsPulls returns true if repository meets the requirements of accepting pulls and has them enabled.

func (repo *Repository) AvatarLink() string

AvatarLink returns a link to the repository's avatar.

func (*Repository) CanCreateBranch

func (repo *Repository) CanCreateBranch() bool

CanCreateBranch returns true if repository meets the requirements for creating new branches.

func (*Repository) CanEnableEditor

func (repo *Repository) CanEnableEditor() bool

CanEnableEditor returns true if repository meets the requirements of web editor.

func (*Repository) CanEnablePulls

func (repo *Repository) CanEnablePulls() bool

CanEnablePulls returns true if repository meets the requirements of accepting pulls.

func (*Repository) CanEnableTimetracker

func (repo *Repository) CanEnableTimetracker() bool

CanEnableTimetracker returns true when the server admin enabled time tracking This overrules IsTimetrackerEnabled

func (repo *Repository) CloneLink() (cl *CloneLink)

CloneLink returns clone URLs of repository.

func (*Repository) ColorFormat

func (repo *Repository) ColorFormat(s fmt.State)

ColorFormat returns a colored string to represent this repo

func (repo *Repository) CommitLink(commitID string) (result string)

CommitLink make link to by commit full ID note: won't check whether it's an right id

func (*Repository) ComposeCompareURL

func (repo *Repository) ComposeCompareURL(oldCommitID, newCommitID string) string

ComposeCompareURL returns the repository comparison URL

func (*Repository) ComposeDocumentMetas

func (repo *Repository) ComposeDocumentMetas() map[string]string

ComposeDocumentMetas composes a map of metas for properly rendering documents

func (*Repository) ComposeMetas

func (repo *Repository) ComposeMetas() map[string]string

ComposeMetas composes a map of metas for properly rendering issue links and external issue trackers.

func (*Repository) CustomAvatarRelativePath

func (repo *Repository) CustomAvatarRelativePath() string

CustomAvatarRelativePath returns repository custom avatar file path.

func (*Repository) DescriptionHTML

func (repo *Repository) DescriptionHTML() template.HTML

DescriptionHTML does special handles to description and return HTML string.

func (*Repository) FullName

func (repo *Repository) FullName() string

FullName returns the repository full name

func (*Repository) GetBaseRepo

func (repo *Repository) GetBaseRepo() (err error)

GetBaseRepo populates repo.BaseRepo for a fork repository and returns an error on failure (NOTE: no error is returned for non-fork repositories, and BaseRepo will be left untouched)

func (*Repository) GetCommitsCountCacheKey

func (repo *Repository) GetCommitsCountCacheKey(contextName string, isRef bool) string

GetCommitsCountCacheKey returns cache key used for commits count caching.

func (*Repository) GetOriginalURLHostname

func (repo *Repository) GetOriginalURLHostname() string

GetOriginalURLHostname returns the hostname of a URL or the URL

func (*Repository) GetOwner

func (repo *Repository) GetOwner(ctx context.Context) (err error)

GetOwner returns the repository owner

func (*Repository) GetTrustModel

func (repo *Repository) GetTrustModel() TrustModelType

GetTrustModel will get the TrustModel for the repo or the default trust model

func (*Repository) GetUnit

func (repo *Repository) GetUnit(tp unit.Type) (*RepoUnit, error)

GetUnit returns a RepoUnit object

func (*Repository) GetUnitCtx

func (repo *Repository) GetUnitCtx(ctx context.Context, tp unit.Type) (*RepoUnit, error)

GetUnitCtx returns a RepoUnit object

func (*Repository) GitConfigPath

func (repo *Repository) GitConfigPath() string

GitConfigPath returns the repository git config path

func (*Repository) HTMLURL

func (repo *Repository) HTMLURL() string

HTMLURL returns the repository HTML URL

func (*Repository) HasWiki

func (repo *Repository) HasWiki() bool

HasWiki returns true if repository has wiki.

func (*Repository) IsBeingCreated

func (repo *Repository) IsBeingCreated() bool

IsBeingCreated indicates that repository is being migrated or forked

func (*Repository) IsBeingMigrated

func (repo *Repository) IsBeingMigrated() bool

IsBeingMigrated indicates that repository is being migrated

func (*Repository) IsBroken

func (repo *Repository) IsBroken() bool

IsBroken indicates that repository is broken

func (*Repository) IsDependenciesEnabled

func (repo *Repository) IsDependenciesEnabled() bool

IsDependenciesEnabled returns if dependencies are enabled and returns the default setting if not set.

func (*Repository) IsDependenciesEnabledCtx

func (repo *Repository) IsDependenciesEnabledCtx(ctx context.Context) bool

IsDependenciesEnabledCtx returns if dependencies are enabled and returns the default setting if not set.

func (*Repository) IsGenerated

func (repo *Repository) IsGenerated() bool

IsGenerated returns whether _this_ repository was generated from a template

func (*Repository) IsOwnedBy

func (repo *Repository) IsOwnedBy(userID int64) bool

IsOwnedBy returns true when user owns this repository

func (*Repository) IsTimetrackerEnabled

func (repo *Repository) IsTimetrackerEnabled() bool

IsTimetrackerEnabled returns whether or not the timetracker is enabled. It returns the default value from config if an error occurs.

func (*Repository) IsTimetrackerEnabledCtx

func (repo *Repository) IsTimetrackerEnabledCtx(ctx context.Context) bool

IsTimetrackerEnabledCtx returns whether or not the timetracker is enabled. It returns the default value from config if an error occurs.

func (repo *Repository) Link() string

Link returns the repository link

func (*Repository) LoadUnits

func (repo *Repository) LoadUnits(ctx context.Context) (err error)

LoadUnits loads repo units into repo.Units

func (*Repository) MustGetUnit

func (repo *Repository) MustGetUnit(tp unit.Type) *RepoUnit

MustGetUnit always returns a RepoUnit object

func (*Repository) MustOwner

func (repo *Repository) MustOwner() *user_model.User

MustOwner always returns a valid *user_model.User object to avoid conceptually impossible error handling. It creates a fake object that contains error details when error occurs.

func (repo *Repository) RelAvatarLink() string

RelAvatarLink returns a relative link to the repository's avatar.

func (*Repository) RepoPath

func (repo *Repository) RepoPath() string

RepoPath returns the repository path

func (*Repository) SanitizedOriginalURL

func (repo *Repository) SanitizedOriginalURL() string

SanitizedOriginalURL returns a sanitized OriginalURL

func (*Repository) TemplateRepo

func (repo *Repository) TemplateRepo() *Repository

TemplateRepo returns the repository, which is template of this repository

func (*Repository) UnitEnabled

func (repo *Repository) UnitEnabled(tp unit.Type) bool

UnitEnabled if this repository has the given unit enabled

func (repo *Repository) WikiCloneLink() *CloneLink

WikiCloneLink returns clone URLs of repository wiki.

func (*Repository) WikiPath

func (repo *Repository) WikiPath() string

WikiPath returns wiki data path for given repository.

type RepositoryStatus

type RepositoryStatus int

RepositoryStatus defines the status of repository

const (
	RepositoryReady           RepositoryStatus = iota // a normal repository
	RepositoryBeingMigrated                           // repository is migrating
	RepositoryPendingTransfer                         // repository pending in ownership transfer state
	RepositoryBroken                                  // repository is in a permanently broken state
)

all kinds of RepositoryStatus

type Star

type Star struct {
	ID          int64              `xorm:"pk autoincr"`
	UID         int64              `xorm:"UNIQUE(s)"`
	RepoID      int64              `xorm:"UNIQUE(s)"`
	CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
}

Star represents a starred repo by an user.

type Topic

type Topic struct {
	ID          int64  `xorm:"pk autoincr"`
	Name        string `xorm:"UNIQUE VARCHAR(50)"`
	RepoCount   int
	CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
}

Topic represents a topic of repositories

func AddTopic

func AddTopic(repoID int64, topicName string) (*Topic, error)

AddTopic adds a topic name to a repository (if it does not already have it)

func DeleteTopic

func DeleteTopic(repoID int64, topicName string) (*Topic, error)

DeleteTopic removes a topic name from a repository (if it has it)

func FindTopics

func FindTopics(opts *FindTopicOptions) ([]*Topic, int64, error)

FindTopics retrieves the topics via FindTopicOptions

func GetRepoTopicByName

func GetRepoTopicByName(repoID int64, topicName string) (*Topic, error)

GetRepoTopicByName retrieves topic from name for a repo if it exist

func GetTopicByName

func GetTopicByName(name string) (*Topic, error)

GetTopicByName retrieves topic by name

type TrustModelType

type TrustModelType int

TrustModelType defines the types of trust model for this repository

const (
	DefaultTrustModel TrustModelType = iota // default trust model
	CommitterTrustModel
	CollaboratorTrustModel
	CollaboratorCommitterTrustModel
)

kinds of TrustModel

func ToTrustModel

func ToTrustModel(model string) TrustModelType

ToTrustModel converts a string to a TrustModelType

func (TrustModelType) String

func (t TrustModelType) String() string

String converts a TrustModelType to a string

type UnitConfig

type UnitConfig struct{}

UnitConfig describes common unit config

func (*UnitConfig) FromDB

func (cfg *UnitConfig) FromDB(bs []byte) error

FromDB fills up a UnitConfig from serialized format.

func (*UnitConfig) ToDB

func (cfg *UnitConfig) ToDB() ([]byte, error)

ToDB exports a UnitConfig to a serialized format.

type Watch

type Watch struct {
	ID          int64              `xorm:"pk autoincr"`
	UserID      int64              `xorm:"UNIQUE(watch)"`
	RepoID      int64              `xorm:"UNIQUE(watch)"`
	Mode        WatchMode          `xorm:"SMALLINT NOT NULL DEFAULT 1"`
	CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
}

Watch is connection request for receiving repository notification.

func GetWatch

func GetWatch(ctx context.Context, userID, repoID int64) (Watch, error)

GetWatch gets what kind of subscription a user has on a given repository; returns dummy record if none found

func GetWatchers

func GetWatchers(ctx context.Context, repoID int64) ([]*Watch, error)

GetWatchers returns all watchers of given repository.

type WatchMode

type WatchMode int8

WatchMode specifies what kind of watch the user has on a repository

const (
	// WatchModeNone don't watch
	WatchModeNone WatchMode = iota // 0
	// WatchModeNormal watch repository (from other sources)
	WatchModeNormal // 1
	// WatchModeDont explicit don't auto-watch
	WatchModeDont // 2
	// WatchModeAuto watch repository (from AutoWatchOnChanges)
	WatchModeAuto // 3
)

Jump to

Keyboard shortcuts

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