files

package
v1.21.8 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 26 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyDiffPatch added in v1.17.0

ApplyDiffPatch applies a patch to the given repository

func ChangeRepoFiles added in v1.20.0

ChangeRepoFiles adds, updates or removes multiple files in the given repository

func CherryPick added in v1.17.0

func CherryPick(ctx context.Context, repo *repo_model.Repository, doer *user_model.User, revert bool, opts *ApplyDiffPatchOptions) (*structs.FileResponse, error)

CherryPick cherrypicks or reverts a commit to the given repository

func CleanUploadFileName

func CleanUploadFileName(name string) string

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

func CountDivergingCommits

func CountDivergingCommits(ctx context.Context, repo *repo_model.Repository, branch string) (*git.DivergeObject, error)

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

func CreateCommitStatus

func CreateCommitStatus(ctx context.Context, repo *repo_model.Repository, creator *user_model.User, sha string, status *git_model.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 CreateOrUpdateFile added in v1.20.0

func CreateOrUpdateFile(ctx context.Context, t *TemporaryUploadRepository, file *ChangeRepoFile, contentStore *lfs.ContentStore, repoID int64, hasOldBranch bool) error

CreateOrUpdateFile handles creating or updating a file for ChangeRepoFiles

func GetAuthorAndCommitterUsers

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

GetAuthorAndCommitterUsers Gets the author and committer user objects from the IdentityOptions

func GetBlobBySHA

func GetBlobBySHA(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, sha string) (*api.GitBlobResponse, error)

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

func GetContents

func GetContents(ctx context.Context, repo *repo_model.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

func GetContentsOrList(ctx context.Context, repo *repo_model.Repository, treePath, ref string) (any, 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

func GetDiffPreview(ctx context.Context, repo *repo_model.Repository, branch, treePath, content string) (*gitdiff.Diff, error)

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

func GetFileCommitResponse

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

GetFileCommitResponse Constructs a FileCommitResponse from a Commit object

func GetFileResponseFromCommit

func GetFileResponseFromCommit(ctx context.Context, repo *repo_model.Repository, commit *git.Commit, branch, treeName string) (*api.FileResponse, error)

GetFileResponseFromCommit Constructs a FileResponse from a Commit object

func GetFileResponseFromFilesResponse added in v1.20.0

func GetFileResponseFromFilesResponse(filesResponse *api.FilesResponse, index int) *api.FileResponse

constructs a FileResponse with the file at the index from FilesResponse

func GetFilesResponseFromCommit added in v1.20.0

func GetFilesResponseFromCommit(ctx context.Context, repo *repo_model.Repository, commit *git.Commit, branch string, treeNames []string) (*api.FilesResponse, error)

func GetPayloadCommitVerification

func GetPayloadCommitVerification(ctx context.Context, commit *git.Commit) *structs.PayloadCommitVerification

GetPayloadCommitVerification returns the verification information of a commit

func GetTreeBySHA

func GetTreeBySHA(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, sha string, page, perPage int, recursive bool) (*api.GitTreeResponse, error)

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

func UploadRepoFiles

func UploadRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *user_model.User, opts *UploadRepoFileOptions) error

UploadRepoFiles uploads files to the given repository

func VerifyBranchProtection

func VerifyBranchProtection(ctx context.Context, repo *repo_model.Repository, doer *user_model.User, branchName string, treePaths []string) error

VerifyBranchProtection verify the branch protection for modifying the given treePath on the given branch

Types

type ApplyDiffPatchOptions added in v1.17.0

type ApplyDiffPatchOptions struct {
	LastCommitID string
	OldBranch    string
	NewBranch    string
	Message      string
	Content      string
	SHA          string
	Author       *IdentityOptions
	Committer    *IdentityOptions
	Dates        *CommitDateOptions
	Signoff      bool
}

ApplyDiffPatchOptions holds the repository diff patch update options

func (*ApplyDiffPatchOptions) Validate added in v1.17.0

func (opts *ApplyDiffPatchOptions) Validate(ctx context.Context, repo *repo_model.Repository, doer *user_model.User) error

Validate validates the provided options

type ChangeRepoFile added in v1.20.0

type ChangeRepoFile struct {
	Operation     string
	TreePath      string
	FromTreePath  string
	ContentReader io.Reader
	SHA           string
	Options       *RepoFileOptions
}

type ChangeRepoFilesOptions added in v1.20.0

type ChangeRepoFilesOptions struct {
	LastCommitID string
	OldBranch    string
	NewBranch    string
	Message      string
	Files        []*ChangeRepoFile
	Author       *IdentityOptions
	Committer    *IdentityOptions
	Dates        *CommitDateOptions
	Signoff      bool
}

ChangeRepoFilesOptions holds the repository files update options

type CommitDateOptions

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

CommitDateOptions store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE

type ContentType

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 GetObjectTypeFromTreeEntry added in v1.17.4

func GetObjectTypeFromTreeEntry(entry *git.TreeEntry) ContentType

GetObjectTypeFromTreeEntry check what content is behind it

func (*ContentType) String

func (ct *ContentType) String() string

String gets the string of ContentType

type IdentityOptions

type IdentityOptions struct {
	Name  string
	Email string
}

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

type RepoFileOptions added in v1.20.0

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

type TemporaryUploadRepository

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

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

func NewTemporaryUploadRepository

func NewTemporaryUploadRepository(ctx context.Context, repo *repo_model.Repository) (*TemporaryUploadRepository, error)

NewTemporaryUploadRepository creates a new temporary upload repository

func (*TemporaryUploadRepository) AddObjectToIndex

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) Clone

func (t *TemporaryUploadRepository) Clone(branch string, bare bool) error

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

func (*TemporaryUploadRepository) Close

func (t *TemporaryUploadRepository) Close()

Close the repository cleaning up all files

func (*TemporaryUploadRepository) CommitTree

func (t *TemporaryUploadRepository) CommitTree(parent string, author, committer *user_model.User, treeHash, message string, signoff bool) (string, error)

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

func (*TemporaryUploadRepository) CommitTreeWithDate

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

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

func (*TemporaryUploadRepository) DiffIndex

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

DiffIndex returns a Diff of the current index to the head

func (*TemporaryUploadRepository) GetBranchCommit

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

GetBranchCommit Gets the commit object of the given branch

func (*TemporaryUploadRepository) GetCommit

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

GetCommit Gets the commit object of the given commit ID

func (*TemporaryUploadRepository) GetLastCommit

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

GetLastCommit gets the last commit ID SHA of the repo

func (*TemporaryUploadRepository) GetLastCommitByRef

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

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

func (*TemporaryUploadRepository) HashObject

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

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

func (*TemporaryUploadRepository) Init added in v1.17.0

func (t *TemporaryUploadRepository) Init() error

Init the repository

func (*TemporaryUploadRepository) LsFiles

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

LsFiles checks if the given filename arguments are in the index

func (*TemporaryUploadRepository) Push

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

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

func (*TemporaryUploadRepository) RefreshIndex added in v1.21.5

func (t *TemporaryUploadRepository) RefreshIndex() error

RefreshIndex looks at the current index and checks to see if merges or updates are needed by checking stat() information.

func (*TemporaryUploadRepository) RemoveFilesFromIndex

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

RemoveFilesFromIndex removes the given files from the index

func (*TemporaryUploadRepository) SetDefaultIndex

func (t *TemporaryUploadRepository) SetDefaultIndex() error

SetDefaultIndex sets the git index to our HEAD

func (*TemporaryUploadRepository) WriteTree

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

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

type UploadRepoFileOptions

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

UploadRepoFileOptions contains the uploaded repository file options

Jump to

Keyboard shortcuts

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