Documentation
¶
Index ¶
- Constants
- Variables
- func CanUserDelete(ctx context.Context, repo *repo_model.Repository, user *user_model.User) (bool, error)
- func CanUserForkBetweenOwners(id1, id2 int64) bool
- func CanUserForkRepo(ctx context.Context, 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 CheckInitRepository(ctx context.Context, owner, name, objectFormatName string) (err error)
- func CreateDelegateHooks(repoPath string) (err error)
- func CreateTemporaryPath(prefix string) (string, error)
- func FullPushingEnvironment(author, committer *user_model.User, repo *repo_model.Repository, ...) []string
- func GetLicense(name string, values *LicenseValues) ([]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 LoadRepoConfig() error
- func LoadTemplateLabelsByDisplayName(displayName string) ([]*label.Label, error)
- func LocalCopyPath() string
- func PushUpdateAddTag(ctx context.Context, 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(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository) error
- func SyncRepoBranches(ctx context.Context, repoID, doerID int64) (int64, error)
- func SyncRepoBranchesWithRepo(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, ...) (int64, error)
- func SyncRepoTags(ctx context.Context, repoID int64) error
- func ToAPIPayloadCommit(ctx context.Context, emailUsers map[string]*user_model.User, ...) (*api.PayloadCommit, 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 LicenseValues
- type OptionFile
- type PushCommit
- type PushCommits
- type PushTrigger
- type PushUpdateOptions
- 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) IsUpdateBranch() bool
- func (opts *PushUpdateOptions) IsUpdateRef() bool
- func (opts *PushUpdateOptions) RefName() string
- func (opts *PushUpdateOptions) RepoFullName() 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"
EnvPushTrigger = "GITEA_PUSH_TRIGGER"
EnvIsInternal = "GITEA_INTERNAL_PUSH"
EnvAppURL = "GITEA_ROOT_URL"
EnvActionPerm = "GITEA_ACTION_PERM"
)
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
// LabelTemplateFiles contains the label template files, each item has its DisplayName and Description
LabelTemplateFiles []OptionFile
)
Functions ¶
func CanUserDelete ¶ added in v1.17.0
func CanUserDelete(ctx context.Context, repo *repo_model.Repository, user *user_model.User) (bool, error)
CanUserDelete returns true if user could delete the repository
func CanUserForkBetweenOwners ¶ added in v1.23.0
func CanUserForkBetweenOwners(id1, id2 int64) bool
CanUserForkBetweenOwners returns true if user can fork between owners. By default, a user can fork a repository from another owner, but not from themselves. Many users really like to fork their own repositories, so add an experimental setting to allow this.
func CanUserForkRepo ¶ added in v1.17.0
func CanUserForkRepo(ctx context.Context, 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
func CheckDelegateHooks(repoPath string) ([]string, error)
CheckDelegateHooks checks the hooks scripts for the repo
func CheckInitRepository ¶ added in v1.21.0
func CheckInitRepository(ctx context.Context, owner, name, objectFormatName string) (err error)
func CreateDelegateHooks ¶ added in v1.12.0
func CreateDelegateHooks(repoPath string) (err error)
CreateDelegateHooks creates all the hooks scripts for the repo
func CreateTemporaryPath ¶ added in v1.17.0
func CreateTemporaryPath(prefix string) (string, error)
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 GetLicense ¶ added in v1.21.0
func GetLicense(name string, values *LicenseValues) ([]byte, error)
func InitializeLabels ¶ added in v1.17.0
func InitializeLabels(ctx context.Context, id int64, labelTemplate string, isOrg bool) error
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 LoadRepoConfig ¶ added in v1.17.0
func LoadRepoConfig() error
LoadRepoConfig loads the repository config
func LoadTemplateLabelsByDisplayName ¶ added in v1.19.1
func LoadTemplateLabelsByDisplayName(displayName string) ([]*label.Label, error)
LoadTemplateLabelsByDisplayName loads a label template by its display name
func LocalCopyPath ¶ added in v1.17.0
func LocalCopyPath() string
LocalCopyPath returns the local repository temporary copy path.
func PushUpdateAddTag ¶ added in v1.12.0
func PushUpdateAddTag(ctx context.Context, 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
func RemoveTemporaryPath(basePath string) error
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(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository) error
SyncReleasesWithTags synchronizes release table with repository tags
func SyncRepoBranches ¶ added in v1.21.0
func SyncRepoBranches(ctx context.Context, repoID, doerID int64) (int64, error)
SyncRepoBranches synchronizes branch table with repository branches
func SyncRepoBranchesWithRepo ¶ added in v1.21.0
func SyncRepoBranchesWithRepo(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, doerID int64) (int64, error)
func SyncRepoTags ¶ added in v1.22.0
func SyncRepoTags(ctx context.Context, repoID int64) error
SyncRepoTags synchronizes releases table with repository tags
func ToAPIPayloadCommit ¶ added in v1.23.0
func ToAPIPayloadCommit(ctx context.Context, emailUsers map[string]*user_model.User, repoPath, repoLink string, commit *PushCommit) (*api.PayloadCommit, error)
ToAPIPayloadCommit converts a single PushCommit to an api.PayloadCommit object.
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
func WikiRemoteURL ¶ added in v1.13.0
func WikiRemoteURL(ctx context.Context, remote string) string
WikiRemoteURL returns accessible repository URL for wiki if exists. Otherwise, it returns an empty string.
Types ¶
type LicenseValues ¶ added in v1.21.0
type LicenseValues struct {
Owner string
Email string
Repo string
Year string
}
type OptionFile ¶ added in v1.19.1
type OptionFile struct {
DisplayName string
Description string
}
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
}
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(ctx context.Context, 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 PushTrigger ¶ added in v1.22.0
type PushTrigger string
const (
PushTriggerPRMergeToBase PushTrigger = "pr-merge-to-base"
PushTriggerPRUpdateWithBase PushTrigger = "pr-update-with-base"
)
type PushUpdateOptions ¶ added in v1.14.0
type PushUpdateOptions struct {
PusherID int64
PusherName string
RepoUserName string
RepoName string
RefFullName git.RefName // branch, tag or other name to push
OldCommitID string
NewCommitID string
}
PushUpdateOptions defines the push update options
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) 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