Documentation ¶
Index ¶
- Constants
- Variables
- func AddCollaborator(repo *repo_model.Repository, u *user_model.User) error
- func CanUserDelete(repo *repo_model.Repository, user *user_model.User) (bool, error)
- func CanUserForkRepo(user *user_model.User, repo *repo_model.Repository) (bool, error)
- func CheckDaemonExportOK(ctx context.Context, repo *repo_model.Repository) error
- func CheckDelegateHooks(repoPath string) ([]string, error)
- func CleanUpMigrateInfo(ctx context.Context, repo *repo_model.Repository) (*repo_model.Repository, error)
- func CreateDelegateHooks(repoPath string) error
- func CreateRepository(doer, u *user_model.User, opts CreateRepoOptions) (*repo_model.Repository, error)
- func CreateRepositoryByExample(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository, ...) (err error)
- func CreateTemporaryPath(prefix string) (string, error)
- func FullPushingEnvironment(author, committer *user_model.User, repo *repo_model.Repository, ...) []string
- func GenerateGitContent(ctx context.Context, templateRepo, generateRepo *repo_model.Repository) error
- func GenerateRepository(ctx context.Context, doer, owner *user_model.User, ...) (_ *repo_model.Repository, err error)
- func GetLabelTemplateFile(name string) ([][3]string, error)
- func GetRepoInitFile(tp, name string) ([]byte, error)
- func InitializeLabels(ctx context.Context, id int64, labelTemplate string, isOrg bool) error
- func InternalPushingEnvironment(doer *user_model.User, repo *repo_model.Repository) []string
- func IsErrIssueLabelTemplateLoad(err error) bool
- func IsForcePush(ctx context.Context, opts *PushUpdateOptions) (bool, error)
- func LoadLabelsFormatted(labelTemplate string) (string, error)
- func LoadRepoConfig()
- func LocalCopyPath() string
- func MigrateRepositoryGitData(ctx context.Context, u *user_model.User, repo *repo_model.Repository, ...) (*repo_model.Repository, error)
- func PushUpdateAddTag(repo *repo_model.Repository, gitRepo *git.Repository, ...) error
- func PushingEnvironment(doer *user_model.User, repo *repo_model.Repository) []string
- func RemoveTemporaryPath(basePath string) error
- func StoreMissingLfsObjectsInRepository(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, ...) error
- func SyncReleasesWithTags(repo *repo_model.Repository, gitRepo *git.Repository) error
- func UpdateRepoSize(ctx context.Context, repo *repo_model.Repository) error
- func UpdateRepository(ctx context.Context, repo *repo_model.Repository, visibilityChanged bool) (err error)
- func WikiRemoteURL(ctx context.Context, remote string) string
- type CreateRepoOptions
- type ErrIssueLabelTemplateLoad
- type GenerateRepoOptions
- type GiteaTemplate
- type PushCommit
- type PushCommits
- type PushUpdateOptions
- func (opts *PushUpdateOptions) BranchName() string
- func (opts *PushUpdateOptions) IsBranch() bool
- func (opts *PushUpdateOptions) IsDelBranch() bool
- func (opts *PushUpdateOptions) IsDelRef() bool
- func (opts *PushUpdateOptions) IsDelTag() bool
- func (opts *PushUpdateOptions) IsNewBranch() bool
- func (opts *PushUpdateOptions) IsNewRef() bool
- func (opts *PushUpdateOptions) IsNewTag() bool
- func (opts *PushUpdateOptions) IsTag() bool
- func (opts *PushUpdateOptions) IsUpdateBranch() bool
- func (opts *PushUpdateOptions) IsUpdateRef() bool
- func (opts *PushUpdateOptions) RefName() string
- func (opts *PushUpdateOptions) RepoFullName() string
- func (opts *PushUpdateOptions) TagName() string
Constants ¶
const ( EnvRepoName = "GITEA_REPO_NAME" EnvRepoUsername = "GITEA_REPO_USER_NAME" EnvRepoID = "GITEA_REPO_ID" EnvRepoIsWiki = "GITEA_REPO_IS_WIKI" EnvPusherName = "GITEA_PUSHER_NAME" EnvPusherEmail = "GITEA_PUSHER_EMAIL" EnvPusherID = "GITEA_PUSHER_ID" EnvKeyID = "GITEA_KEY_ID" // public key ID EnvDeployKeyID = "GITEA_DEPLOY_KEY_ID" EnvPRID = "GITEA_PR_ID" EnvIsInternal = "GITEA_INTERNAL_PUSH" EnvAppURL = "GITEA_ROOT_URL" )
env keys for git hooks need
Variables ¶
var ( // Gitignores contains the gitiginore files Gitignores []string // Licenses contains the license files Licenses []string // Readmes contains the readme files Readmes []string // LabelTemplates contains the label template files and the list of labels for each file LabelTemplates map[string]string )
Functions ¶
func AddCollaborator ¶ added in v1.17.4
func AddCollaborator(repo *repo_model.Repository, u *user_model.User) error
AddCollaborator adds new collaboration to a repository with default access mode.
func CanUserDelete ¶ added in v1.17.0
func CanUserDelete(repo *repo_model.Repository, user *user_model.User) (bool, error)
CanUserDelete returns true if user could delete the repository
func CanUserForkRepo ¶ added in v1.17.0
func CanUserForkRepo(user *user_model.User, repo *repo_model.Repository) (bool, error)
CanUserForkRepo returns true if specified user can fork repository.
func CheckDaemonExportOK ¶ added in v1.17.0
func CheckDaemonExportOK(ctx context.Context, repo *repo_model.Repository) error
CheckDaemonExportOK creates/removes git-daemon-export-ok for git-daemon...
func CheckDelegateHooks ¶ added in v1.12.0
CheckDelegateHooks checks the hooks scripts for the repo
func CleanUpMigrateInfo ¶
func CleanUpMigrateInfo(ctx context.Context, repo *repo_model.Repository) (*repo_model.Repository, error)
CleanUpMigrateInfo finishes migrating repository and/or wiki with things that don't need to be done for mirrors.
func CreateDelegateHooks ¶ added in v1.12.0
CreateDelegateHooks creates all the hooks scripts for the repo
func CreateRepository ¶ added in v1.12.0
func CreateRepository(doer, u *user_model.User, opts CreateRepoOptions) (*repo_model.Repository, error)
CreateRepository creates a repository for the user/organization.
func CreateRepositoryByExample ¶ added in v1.17.4
func CreateRepositoryByExample(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository, overwriteOrAdopt bool) (err error)
CreateRepositoryByExample creates a repository for the user/organization.
func CreateTemporaryPath ¶ added in v1.17.0
CreateTemporaryPath creates a temporary path
func FullPushingEnvironment ¶ added in v1.17.0
func FullPushingEnvironment(author, committer *user_model.User, repo *repo_model.Repository, repoName string, prID int64) []string
FullPushingEnvironment returns an os environment to allow hooks to work on push
func GenerateGitContent ¶ added in v1.12.0
func GenerateGitContent(ctx context.Context, templateRepo, generateRepo *repo_model.Repository) error
GenerateGitContent generates git content from a template repository
func GenerateRepository ¶ added in v1.12.0
func GenerateRepository(ctx context.Context, doer, owner *user_model.User, templateRepo *repo_model.Repository, opts GenerateRepoOptions) (_ *repo_model.Repository, err error)
GenerateRepository generates a repository from a template
func GetLabelTemplateFile ¶ added in v1.17.0
GetLabelTemplateFile loads the label template file by given name, then parses and returns a list of name-color pairs and optionally description.
func GetRepoInitFile ¶ added in v1.17.0
GetRepoInitFile returns repository init files
func InitializeLabels ¶ added in v1.17.0
InitializeLabels adds a label set to a repository using a template
func InternalPushingEnvironment ¶ added in v1.17.0
func InternalPushingEnvironment(doer *user_model.User, repo *repo_model.Repository) []string
InternalPushingEnvironment returns an os environment to switch off hooks on push It is recommended to avoid using this unless you are pushing within a transaction or if you absolutely are sure that post-receive and pre-receive will do nothing We provide the full pushing-environment for other hook providers
func IsErrIssueLabelTemplateLoad ¶ added in v1.17.0
IsErrIssueLabelTemplateLoad checks if an error is a ErrIssueLabelTemplateLoad.
func IsForcePush ¶ added in v1.14.0
func IsForcePush(ctx context.Context, opts *PushUpdateOptions) (bool, error)
IsForcePush detect if a push is a force push
func LoadLabelsFormatted ¶ added in v1.17.0
LoadLabelsFormatted loads the labels' list of a template file as a string separated by comma
func LoadRepoConfig ¶ added in v1.17.0
func LoadRepoConfig()
LoadRepoConfig loads the repository config
func LocalCopyPath ¶ added in v1.17.0
func LocalCopyPath() string
LocalCopyPath returns the local repository temporary copy path.
func MigrateRepositoryGitData ¶
func MigrateRepositoryGitData(ctx context.Context, u *user_model.User, repo *repo_model.Repository, opts migration.MigrateOptions, httpTransport *http.Transport, ) (*repo_model.Repository, error)
MigrateRepositoryGitData starts migrating git related data after created migrating repository
func PushUpdateAddTag ¶ added in v1.12.0
func PushUpdateAddTag(repo *repo_model.Repository, gitRepo *git.Repository, tagName, sha1, refname string) error
PushUpdateAddTag must be called for any push actions to add tag
func PushingEnvironment ¶ added in v1.17.0
func PushingEnvironment(doer *user_model.User, repo *repo_model.Repository) []string
PushingEnvironment returns an os environment to allow hooks to work on push
func RemoveTemporaryPath ¶ added in v1.17.0
RemoveTemporaryPath removes the temporary path
func StoreMissingLfsObjectsInRepository ¶ added in v1.15.0
func StoreMissingLfsObjectsInRepository(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, lfsClient lfs.Client) error
StoreMissingLfsObjectsInRepository downloads missing LFS objects
func SyncReleasesWithTags ¶
func SyncReleasesWithTags(repo *repo_model.Repository, gitRepo *git.Repository) error
SyncReleasesWithTags synchronizes release table with repository tags
func UpdateRepoSize ¶ added in v1.17.0
func UpdateRepoSize(ctx context.Context, repo *repo_model.Repository) error
UpdateRepoSize updates the repository size, calculating it using getDirectorySize
func UpdateRepository ¶ added in v1.17.0
func UpdateRepository(ctx context.Context, repo *repo_model.Repository, visibilityChanged bool) (err error)
UpdateRepository updates a repository with db context
Types ¶
type CreateRepoOptions ¶ added in v1.17.4
type CreateRepoOptions struct { Name string Description string OriginalURL string GitServiceType api.GitServiceType Gitignores string IssueLabels string License string Readme string DefaultBranch string IsPrivate bool IsMirror bool IsTemplate bool AutoInit bool Status repo_model.RepositoryStatus TrustModel repo_model.TrustModelType MirrorInterval string }
CreateRepoOptions contains the create repository options
type ErrIssueLabelTemplateLoad ¶ added in v1.17.0
ErrIssueLabelTemplateLoad represents a "ErrIssueLabelTemplateLoad" kind of error.
func (ErrIssueLabelTemplateLoad) Error ¶ added in v1.17.0
func (err ErrIssueLabelTemplateLoad) Error() string
type GenerateRepoOptions ¶ added in v1.17.0
type GenerateRepoOptions struct { Name string DefaultBranch string Description string Private bool GitContent bool Topics bool GitHooks bool Webhooks bool Avatar bool IssueLabels bool }
GenerateRepoOptions contains the template units to generate
func (GenerateRepoOptions) IsValid ¶ added in v1.17.0
func (gro GenerateRepoOptions) IsValid() bool
IsValid checks whether at least one option is chosen for generation
type GiteaTemplate ¶ added in v1.17.0
GiteaTemplate holds information about a .gitea/template file
func (GiteaTemplate) Globs ¶ added in v1.17.0
func (gt GiteaTemplate) Globs() []glob.Glob
Globs parses the .gitea/template globs or returns them if they were already parsed
type PushCommit ¶ added in v1.12.0
type PushCommit struct { Sha1 string Message string AuthorEmail string AuthorName string CommitterEmail string CommitterName string Timestamp time.Time }
PushCommit represents a commit in a push operation.
func CommitToPushCommit ¶ added in v1.12.0
func CommitToPushCommit(commit *git.Commit) *PushCommit
CommitToPushCommit transforms a git.Commit to PushCommit type.
type PushCommits ¶ added in v1.12.0
type PushCommits struct { Commits []*PushCommit HeadCommit *PushCommit CompareURL string Len int // contains filtered or unexported fields }
PushCommits represents list of commits in a push operation.
func GitToPushCommits ¶ added in v1.16.0
func GitToPushCommits(gitCommits []*git.Commit) *PushCommits
GitToPushCommits transforms a list of git.Commits to PushCommits type.
func NewPushCommits ¶ added in v1.12.0
func NewPushCommits() *PushCommits
NewPushCommits creates a new PushCommits object.
func (*PushCommits) AvatarLink ¶ added in v1.12.0
func (pc *PushCommits) AvatarLink(email string) string
AvatarLink tries to match user in database with e-mail in order to show custom avatar, and falls back to general avatar link.
func (*PushCommits) ToAPIPayloadCommits ¶ added in v1.12.0
func (pc *PushCommits) ToAPIPayloadCommits(ctx context.Context, repoPath, repoLink string) ([]*api.PayloadCommit, *api.PayloadCommit, error)
ToAPIPayloadCommits converts a PushCommits object to api.PayloadCommit format. It returns all converted commits and, if provided, the head commit or an error otherwise.
type PushUpdateOptions ¶ added in v1.14.0
type PushUpdateOptions struct { PusherID int64 PusherName string RepoUserName string RepoName string RefFullName string // branch, tag or other name to push OldCommitID string NewCommitID string }
PushUpdateOptions defines the push update options
func (*PushUpdateOptions) BranchName ¶ added in v1.14.0
func (opts *PushUpdateOptions) BranchName() string
BranchName returns simple branch name if it's an operation to branch
func (*PushUpdateOptions) IsBranch ¶ added in v1.14.0
func (opts *PushUpdateOptions) IsBranch() bool
IsBranch return true if it's a push to branch
func (*PushUpdateOptions) IsDelBranch ¶ added in v1.14.0
func (opts *PushUpdateOptions) IsDelBranch() bool
IsDelBranch return true if it's a deletion to a branch
func (*PushUpdateOptions) IsDelRef ¶ added in v1.14.0
func (opts *PushUpdateOptions) IsDelRef() bool
IsDelRef return true if it's a deletion to a branch or tag
func (*PushUpdateOptions) IsDelTag ¶ added in v1.14.0
func (opts *PushUpdateOptions) IsDelTag() bool
IsDelTag return true if it's a deletion to a tag
func (*PushUpdateOptions) IsNewBranch ¶ added in v1.14.0
func (opts *PushUpdateOptions) IsNewBranch() bool
IsNewBranch return true if it's the first-time push to a branch
func (*PushUpdateOptions) IsNewRef ¶ added in v1.14.0
func (opts *PushUpdateOptions) IsNewRef() bool
IsNewRef return true if it's a first-time push to a branch, tag or etc.
func (*PushUpdateOptions) IsNewTag ¶ added in v1.14.0
func (opts *PushUpdateOptions) IsNewTag() bool
IsNewTag return true if it's a creation to a tag
func (*PushUpdateOptions) IsTag ¶ added in v1.14.0
func (opts *PushUpdateOptions) IsTag() bool
IsTag return true if it's an operation to a tag
func (*PushUpdateOptions) IsUpdateBranch ¶ added in v1.14.0
func (opts *PushUpdateOptions) IsUpdateBranch() bool
IsUpdateBranch return true if it's not the first push to a branch
func (*PushUpdateOptions) IsUpdateRef ¶ added in v1.14.0
func (opts *PushUpdateOptions) IsUpdateRef() bool
IsUpdateRef return true if it's an update operation
func (*PushUpdateOptions) RefName ¶ added in v1.14.0
func (opts *PushUpdateOptions) RefName() string
RefName returns simple name for ref
func (*PushUpdateOptions) RepoFullName ¶ added in v1.14.0
func (opts *PushUpdateOptions) RepoFullName() string
RepoFullName returns repo full name
func (*PushUpdateOptions) TagName ¶ added in v1.14.0
func (opts *PushUpdateOptions) TagName() string
TagName returns simple tag name if it's an operation to a tag