gitea: code.gitea.io/gitea/modules/repofiles Index | Files

package repofiles

import "code.gitea.io/gitea/modules/repofiles"

Index

Package Files

action.go blob.go commit.go commit_status.go content.go delete.go diff.go file.go repofiles.go temp_repo.go tree.go update.go upload.go verification.go

func CleanUploadFileName Uses

func CleanUploadFileName(name string) string

CleanUploadFileName Trims a filename and returns empty string if it is a .git directory

func CommitRepoAction Uses

func CommitRepoAction(optsList ...*CommitRepoActionOptions) error

CommitRepoAction adds new commit action to the repository, and prepare corresponding webhooks.

func CountDivergingCommits Uses

func CountDivergingCommits(repo *models.Repository, branch string) (*git.DivergeObject, error)

CountDivergingCommits determines how many commits a branch is ahead or behind the repository's base branch

func CreateCommitStatus Uses

func CreateCommitStatus(repo *models.Repository, creator *models.User, sha string, status *models.CommitStatus) error

CreateCommitStatus creates a new CommitStatus given a bunch of parameters NOTE: All text-values will be trimmed from whitespaces. Requires: Repo, Creator, SHA

func CreateOrUpdateRepoFile Uses

func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *UpdateRepoFileOptions) (*structs.FileResponse, error)

CreateOrUpdateRepoFile adds or updates a file in the given repository

func DeleteRepoFile Uses

func DeleteRepoFile(repo *models.Repository, doer *models.User, opts *DeleteRepoFileOptions) (*api.FileResponse, error)

DeleteRepoFile deletes a file in the given repository

func GetAuthorAndCommitterUsers Uses

func GetAuthorAndCommitterUsers(author, committer *IdentityOptions, doer *models.User) (authorUser, committerUser *models.User)

GetAuthorAndCommitterUsers Gets the author and committer user objects from the IdentityOptions

func GetBlobBySHA Uses

func GetBlobBySHA(repo *models.Repository, sha string) (*api.GitBlobResponse, error)

GetBlobBySHA get the GitBlobResponse of a repository using a sha hash.

func GetContents Uses

func GetContents(repo *models.Repository, treePath, ref string, forList bool) (*api.ContentsResponse, error)

GetContents gets the meta data on a file's contents. Ref can be a branch, commit or tag

func GetContentsOrList Uses

func GetContentsOrList(repo *models.Repository, treePath, ref string) (interface{}, error)

GetContentsOrList gets the meta data of a file's contents (*ContentsResponse) if treePath not a tree directory, otherwise a listing of file contents ([]*ContentsResponse). Ref can be a branch, commit or tag

func GetDiffPreview Uses

func GetDiffPreview(repo *models.Repository, branch, treePath, content string) (*gitdiff.Diff, error)

GetDiffPreview produces and returns diff result of a file which is not yet committed.

func GetFileCommitResponse Uses

func GetFileCommitResponse(repo *models.Repository, commit *git.Commit) (*api.FileCommitResponse, error)

GetFileCommitResponse Constructs a FileCommitResponse from a Commit object

func GetFileResponseFromCommit Uses

func GetFileResponseFromCommit(repo *models.Repository, commit *git.Commit, branch, treeName string) (*api.FileResponse, error)

GetFileResponseFromCommit Constructs a FileResponse from a Commit object

func GetPayloadCommitVerification Uses

func GetPayloadCommitVerification(commit *git.Commit) *structs.PayloadCommitVerification

GetPayloadCommitVerification returns the verification information of a commit

func GetTreeBySHA Uses

func GetTreeBySHA(repo *models.Repository, sha string, page, perPage int, recursive bool) (*api.GitTreeResponse, error)

GetTreeBySHA get the GitTreeResponse of a repository using a sha hash.

func PushUpdate Uses

func PushUpdate(repo *models.Repository, branch string, opts PushUpdateOptions) error

PushUpdate must be called for any push actions in order to generates necessary push action history feeds and other operations

func PushUpdates Uses

func PushUpdates(repo *models.Repository, optsList []*PushUpdateOptions) error

PushUpdates generates push action history feeds for push updating multiple refs

func UpdateIssuesCommit Uses

func UpdateIssuesCommit(doer *models.User, repo *models.Repository, commits []*repository.PushCommit, branchName string) error

UpdateIssuesCommit checks if issues are manipulated by commit message.

func UploadRepoFiles Uses

func UploadRepoFiles(repo *models.Repository, doer *models.User, opts *UploadRepoFileOptions) error

UploadRepoFiles uploads files to the given repository

type CommitDateOptions Uses

type CommitDateOptions struct {
    Author    time.Time
    Committer time.Time
}

CommitDateOptions store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE

type CommitRepoActionOptions Uses

type CommitRepoActionOptions struct {
    PushUpdateOptions

    RepoOwnerID int64
    Commits     *repository.PushCommits
}

CommitRepoActionOptions represent options of a new commit action.

type ContentType Uses

type ContentType string

ContentType repo content type

const (
    // ContentTypeRegular regular content type (file)
    ContentTypeRegular ContentType = "file"
    // ContentTypeDir dir content type (dir)
    ContentTypeDir ContentType = "dir"
    // ContentLink link content type (symlink)
    ContentTypeLink ContentType = "symlink"
    // ContentTag submodule content type (submodule)
    ContentTypeSubmodule ContentType = "submodule"
)

The string representations of different content types

func (*ContentType) String Uses

func (ct *ContentType) String() string

String gets the string of ContentType

type DeleteRepoFileOptions Uses

type DeleteRepoFileOptions struct {
    LastCommitID string
    OldBranch    string
    NewBranch    string
    TreePath     string
    Message      string
    SHA          string
    Author       *IdentityOptions
    Committer    *IdentityOptions
    Dates        *CommitDateOptions
}

DeleteRepoFileOptions holds the repository delete file options

type IdentityOptions Uses

type IdentityOptions struct {
    Name  string
    Email string
}

IdentityOptions for a person's identity like an author or committer

type PushUpdateOptions Uses

type PushUpdateOptions struct {
    PusherID     int64
    PusherName   string
    RepoUserName string
    RepoName     string
    RefFullName  string
    OldCommitID  string
    NewCommitID  string
}

PushUpdateOptions defines the push update options

func (PushUpdateOptions) BranchName Uses

func (opts PushUpdateOptions) BranchName() string

BranchName returns simple branch name if it's an operation to branch

func (PushUpdateOptions) IsBranch Uses

func (opts PushUpdateOptions) IsBranch() bool

IsBranch return true if it's a push to branch

func (PushUpdateOptions) IsDelBranch Uses

func (opts PushUpdateOptions) IsDelBranch() bool

IsDelBranch return true if it's a deletion to a branch

func (PushUpdateOptions) IsDelRef Uses

func (opts PushUpdateOptions) IsDelRef() bool

IsDelRef return true if it's a deletion to a branch or tag

func (PushUpdateOptions) IsDelTag Uses

func (opts PushUpdateOptions) IsDelTag() bool

IsDelTag return true if it's a deletion to a tag

func (PushUpdateOptions) IsNewBranch Uses

func (opts PushUpdateOptions) IsNewBranch() bool

IsNewBranch return true if it's the first-time push to a branch

func (PushUpdateOptions) IsNewRef Uses

func (opts PushUpdateOptions) IsNewRef() bool

IsNewRef return true if it's a first-time push to a branch, tag or etc.

func (PushUpdateOptions) IsNewTag Uses

func (opts PushUpdateOptions) IsNewTag() bool

IsNewTag return true if it's a creation to a tag

func (PushUpdateOptions) IsTag Uses

func (opts PushUpdateOptions) IsTag() bool

IsTag return true if it's an operation to a tag

func (PushUpdateOptions) IsUpdateBranch Uses

func (opts PushUpdateOptions) IsUpdateBranch() bool

IsUpdateBranch return true if it's not the first push to a branch

func (PushUpdateOptions) IsUpdateRef Uses

func (opts PushUpdateOptions) IsUpdateRef() bool

IsUpdateRef return true if it's an update operation

func (PushUpdateOptions) RepoFullName Uses

func (opts PushUpdateOptions) RepoFullName() string

RepoFullName returns repo full name

func (PushUpdateOptions) TagName Uses

func (opts PushUpdateOptions) TagName() string

TagName returns simple tag name if it's an operation to a tag

type TemporaryUploadRepository Uses

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

TemporaryUploadRepository is a type to wrap our upload repositories as a shallow clone

func NewTemporaryUploadRepository Uses

func NewTemporaryUploadRepository(repo *models.Repository) (*TemporaryUploadRepository, error)

NewTemporaryUploadRepository creates a new temporary upload repository

func (*TemporaryUploadRepository) AddObjectToIndex Uses

func (t *TemporaryUploadRepository) AddObjectToIndex(mode, objectHash, objectPath string) error

AddObjectToIndex adds the provided object hash to the index with the provided mode and path

func (*TemporaryUploadRepository) CheckAttribute Uses

func (t *TemporaryUploadRepository) CheckAttribute(attribute string, args ...string) (map[string]map[string]string, error)

CheckAttribute checks the given attribute of the provided files

func (*TemporaryUploadRepository) Clone Uses

func (t *TemporaryUploadRepository) Clone(branch string) error

Clone the base repository to our path and set branch as the HEAD

func (*TemporaryUploadRepository) Close Uses

func (t *TemporaryUploadRepository) Close()

Close the repository cleaning up all files

func (*TemporaryUploadRepository) CommitTree Uses

func (t *TemporaryUploadRepository) CommitTree(author, committer *models.User, treeHash string, message string) (string, error)

CommitTree creates a commit from a given tree for the user with provided message

func (*TemporaryUploadRepository) CommitTreeWithDate Uses

func (t *TemporaryUploadRepository) CommitTreeWithDate(author, committer *models.User, treeHash string, message string, authorDate, committerDate time.Time) (string, error)

CommitTreeWithDate creates a commit from a given tree for the user with provided message

func (*TemporaryUploadRepository) DiffIndex Uses

func (t *TemporaryUploadRepository) DiffIndex() (*gitdiff.Diff, error)

DiffIndex returns a Diff of the current index to the head

func (*TemporaryUploadRepository) GetBranchCommit Uses

func (t *TemporaryUploadRepository) GetBranchCommit(branch string) (*git.Commit, error)

GetBranchCommit Gets the commit object of the given branch

func (*TemporaryUploadRepository) GetCommit Uses

func (t *TemporaryUploadRepository) GetCommit(commitID string) (*git.Commit, error)

GetCommit Gets the commit object of the given commit ID

func (*TemporaryUploadRepository) GetLastCommit Uses

func (t *TemporaryUploadRepository) GetLastCommit() (string, error)

GetLastCommit gets the last commit ID SHA of the repo

func (*TemporaryUploadRepository) GetLastCommitByRef Uses

func (t *TemporaryUploadRepository) GetLastCommitByRef(ref string) (string, error)

GetLastCommitByRef gets the last commit ID SHA of the repo by ref

func (*TemporaryUploadRepository) HashObject Uses

func (t *TemporaryUploadRepository) HashObject(content io.Reader) (string, error)

HashObject writes the provided content to the object db and returns its hash

func (*TemporaryUploadRepository) LsFiles Uses

func (t *TemporaryUploadRepository) LsFiles(filenames ...string) ([]string, error)

LsFiles checks if the given filename arguments are in the index

func (*TemporaryUploadRepository) Push Uses

func (t *TemporaryUploadRepository) Push(doer *models.User, commitHash string, branch string) error

Push the provided commitHash to the repository branch by the provided user

func (*TemporaryUploadRepository) RemoveFilesFromIndex Uses

func (t *TemporaryUploadRepository) RemoveFilesFromIndex(filenames ...string) error

RemoveFilesFromIndex removes the given files from the index

func (*TemporaryUploadRepository) SetDefaultIndex Uses

func (t *TemporaryUploadRepository) SetDefaultIndex() error

SetDefaultIndex sets the git index to our HEAD

func (*TemporaryUploadRepository) WriteTree Uses

func (t *TemporaryUploadRepository) WriteTree() (string, error)

WriteTree writes the current index as a tree to the object db and returns its hash

type UpdateRepoFileOptions Uses

type UpdateRepoFileOptions struct {
    LastCommitID string
    OldBranch    string
    NewBranch    string
    TreePath     string
    FromTreePath string
    Message      string
    Content      string
    SHA          string
    IsNewFile    bool
    Author       *IdentityOptions
    Committer    *IdentityOptions
    Dates        *CommitDateOptions
}

UpdateRepoFileOptions holds the repository file update options

type UploadRepoFileOptions Uses

type UploadRepoFileOptions struct {
    LastCommitID string
    OldBranch    string
    NewBranch    string
    TreePath     string
    Message      string
    Files        []string // In UUID format.
}

UploadRepoFileOptions contains the uploaded repository file options

Package repofiles imports 29 packages (graph) and is imported by 13 packages. Updated 2020-02-25. Refresh now. Tools for package owners.