Documentation
¶
Index ¶
- Constants
- Variables
- func CommitMessage(subject, body string) string
- func CreateEnvironmentForPush(ctx context.Context, writeRequest WriteParams) []string
- func GetRefPath(refName string, refType enum.RefType) (string, error)
- func NewRepositoryUID() (string, error)
- func ProvideGITAdapter(config types.Config, ...) (*api.Git, error)
- func RequestIDFrom(ctx context.Context) string
- func ValidateCommitSHA(commitSHA string) bool
- func WithRequestID(parent context.Context, v string) context.Context
- type ArchiveParams
- type BlameParams
- type BlamePart
- type BlamePartPrevious
- type Branch
- type BranchSortOption
- type Commit
- type CommitDivergence
- type CommitDivergenceRequest
- type CommitFileAction
- type CommitFileStats
- type CommitFilesParams
- type CommitFilesResponse
- type CommitNumStatsOutput
- type CommitTag
- type CountCommitsOutput
- type CountCommitsParams
- type CountCommitsShortstatOutput
- type CreateBranchOutput
- type CreateBranchParams
- type CreateCommitTagOutput
- type CreateCommitTagParams
- type CreateRepositoryOutput
- type CreateRepositoryParams
- type DeleteBranchParams
- type DeleteRefParams
- type DeleteRepositoryParams
- type DeleteTagParams
- type DiffCutOutput
- type DiffCutParams
- type DiffFileHeader
- type DiffFileHunkHeaders
- type DiffFileNamesOutput
- type DiffFilesParams
- type DiffParams
- type DiffShortStatOutput
- type DiffStatsOutput
- type File
- type FileAction
- type FileDiff
- type FileInfo
- type FindOversizeFilesOutput
- type FindOversizeFilesParams
- type GeneratePipelineParams
- type GeneratePipelinesOutput
- type GetBlobOutput
- type GetBlobParams
- type GetBranchOutput
- type GetBranchParams
- type GetCommitDivergencesOutput
- type GetCommitDivergencesParams
- type GetCommitOutput
- type GetCommitParams
- type GetDefaultBranchOutput
- type GetDefaultBranchParams
- type GetDiffHunkHeadersOutput
- type GetDiffHunkHeadersParams
- type GetRefParams
- type GetRefResponse
- type GetRepositorySizeOutput
- type GetRepositorySizeParams
- type GetSubmoduleOutput
- type GetSubmoduleParams
- type GetTreeNodeOutput
- type GetTreeNodeParams
- type HashRepositoryOutput
- type HashRepositoryParams
- type Hunk
- type HunkHeader
- type Identity
- type InfoRefsParams
- type Interface
- type IsAncestorOutput
- type IsAncestorParams
- type ListBranchesOutput
- type ListBranchesParams
- type ListCommitTagsOutput
- type ListCommitTagsParams
- type ListCommitsOutput
- type ListCommitsParams
- type ListPathsOutput
- type ListPathsParams
- type ListTreeNodeOutput
- type ListTreeNodeParams
- type MatchFilesOutput
- type MatchFilesParams
- type MergeBaseOutput
- type MergeBaseParams
- type MergeOutput
- type MergeParams
- type MirrorSyncParams
- type PathDetails
- type PathsDetailsOutput
- type PathsDetailsParams
- type PushRemoteParams
- type ReadParams
- type RenameDetails
- type Repository
- type ScanSecretsFinding
- type ScanSecretsOutput
- type ScanSecretsParams
- type Service
- func (s *Service) Archive(ctx context.Context, params ArchiveParams, w io.Writer) error
- func (s *Service) Blame(ctx context.Context, params *BlameParams) (<-chan *BlamePart, <-chan error)
- func (s *Service) CommitDiff(ctx context.Context, params *GetCommitParams, out io.Writer) error
- func (s *Service) CommitFiles(ctx context.Context, params *CommitFilesParams) (CommitFilesResponse, error)
- func (s *Service) CountCommits(ctx context.Context, params *CountCommitsParams) (*CountCommitsOutput, error)
- func (s *Service) CountCommitsWithShortstat(ctx context.Context, params *CountCommitsParams) (*CountCommitsShortstatOutput, error)
- func (s *Service) CreateBranch(ctx context.Context, params *CreateBranchParams) (*CreateBranchOutput, error)
- func (s *Service) CreateCommitTag(ctx context.Context, params *CreateCommitTagParams) (*CreateCommitTagOutput, error)
- func (s *Service) CreateRepository(ctx context.Context, params *CreateRepositoryParams) (*CreateRepositoryOutput, error)
- func (s *Service) DeleteBranch(ctx context.Context, params *DeleteBranchParams) error
- func (s *Service) DeleteRef(ctx context.Context, params DeleteRefParams) error
- func (s *Service) DeleteRepository(ctx context.Context, params *DeleteRepositoryParams) error
- func (s *Service) DeleteRepositoryBestEffort(ctx context.Context, repoUID string) error
- func (s *Service) DeleteTag(ctx context.Context, params *DeleteTagParams) error
- func (s *Service) Diff(ctx context.Context, params *DiffParams, files ...api.FileDiffRequest) (<-chan *FileDiff, <-chan error)
- func (s *Service) DiffCut(ctx context.Context, params *DiffCutParams) (DiffCutOutput, error)
- func (s *Service) DiffFileNames(ctx context.Context, params *DiffParams) (DiffFileNamesOutput, error)
- func (s *Service) DiffFiles(ctx context.Context, params *DiffFilesParams) (string, error)
- func (s *Service) DiffShortStat(ctx context.Context, params *DiffParams) (DiffShortStatOutput, error)
- func (s *Service) DiffStats(ctx context.Context, params *DiffParams) (DiffStatsOutput, error)
- func (s *Service) FindOversizeFiles(ctx context.Context, params *FindOversizeFilesParams) (*FindOversizeFilesOutput, error)
- func (s *Service) GeneratePipeline(ctx context.Context, params *GeneratePipelineParams) (GeneratePipelinesOutput, error)
- func (s *Service) GetBlob(ctx context.Context, params *GetBlobParams) (*GetBlobOutput, error)
- func (s *Service) GetBranch(ctx context.Context, params *GetBranchParams) (*GetBranchOutput, error)
- func (s *Service) GetCommit(ctx context.Context, params *GetCommitParams) (*GetCommitOutput, error)
- func (s *Service) GetCommitDivergences(ctx context.Context, params *GetCommitDivergencesParams) (*GetCommitDivergencesOutput, error)
- func (s *Service) GetDefaultBranch(ctx context.Context, params *GetDefaultBranchParams) (*GetDefaultBranchOutput, error)
- func (s *Service) GetDiffHunkHeaders(ctx context.Context, params GetDiffHunkHeadersParams) (GetDiffHunkHeadersOutput, error)
- func (s *Service) GetInfoRefs(ctx context.Context, w io.Writer, params *InfoRefsParams) error
- func (s *Service) GetRef(ctx context.Context, params GetRefParams) (GetRefResponse, error)
- func (s *Service) GetRepositorySize(ctx context.Context, params *GetRepositorySizeParams) (*GetRepositorySizeOutput, error)
- func (s *Service) GetSubmodule(ctx context.Context, params *GetSubmoduleParams) (*GetSubmoduleOutput, error)
- func (s *Service) GetTreeNode(ctx context.Context, params *GetTreeNodeParams) (*GetTreeNodeOutput, error)
- func (s *Service) HashRepository(ctx context.Context, params *HashRepositoryParams) (*HashRepositoryOutput, error)
- func (s *Service) IsAncestor(ctx context.Context, params IsAncestorParams) (IsAncestorOutput, error)
- func (s *Service) ListBranches(ctx context.Context, params *ListBranchesParams) (*ListBranchesOutput, error)
- func (s *Service) ListCommitSHAs(ctx context.Context, params *ListCommitsParams) ([]string, error)
- func (s *Service) ListCommitTags(ctx context.Context, params *ListCommitTagsParams) (*ListCommitTagsOutput, error)
- func (s *Service) ListCommits(ctx context.Context, params *ListCommitsParams) (*ListCommitsOutput, error)
- func (s *Service) ListPaths(ctx context.Context, params *ListPathsParams) (*ListPathsOutput, error)
- func (s *Service) ListTreeNodes(ctx context.Context, params *ListTreeNodeParams) (*ListTreeNodeOutput, error)
- func (s *Service) MatchFiles(ctx context.Context, params *MatchFilesParams) (*MatchFilesOutput, error)
- func (s *Service) Merge(ctx context.Context, params *MergeParams) (MergeOutput, error)
- func (s *Service) MergeBase(ctx context.Context, params MergeBaseParams) (MergeBaseOutput, error)
- func (s *Service) MirrorSyncRepository(ctx context.Context, params *MirrorSyncParams) (bool, error)
- func (s *Service) PathsDetails(ctx context.Context, params PathsDetailsParams) (PathsDetailsOutput, error)
- func (s *Service) PushRemote(ctx context.Context, params *PushRemoteParams) error
- func (s *Service) RawDiff(ctx context.Context, out io.Writer, params *DiffParams, ...) error
- func (s *Service) ReceiveCommitNumStat(ctx context.Context, ref string, params *ReadParams) (CommitNumStatsOutput, error)
- func (s *Service) ReceiveDiffFileNames(ctx context.Context, params *DiffParams) (DiffFileNamesOutput, error)
- func (s *Service) ReceiveDiffSNumStatus(ctx context.Context, params *DiffParams) (CommitNumStatsOutput, error)
- func (s *Service) ScanSecrets(ctx context.Context, params *ScanSecretsParams) (*ScanSecretsOutput, error)
- func (s *Service) ServicePack(ctx context.Context, params *ServicePackParams) error
- func (s *Service) Summary(ctx context.Context, params SummaryParams) (SummaryOutput, error)
- func (s *Service) SyncRepository(ctx context.Context, params *SyncRepositoryParams) (*SyncRepositoryOutput, error)
- func (s *Service) UpdateDefaultBranch(ctx context.Context, params *UpdateDefaultBranchParams) error
- func (s *Service) UpdateRef(ctx context.Context, params UpdateRefParams) error
- type ServicePackParams
- type Signature
- type SortOrder
- type StreamReader
- type Submodule
- type SummaryOutput
- type SummaryParams
- type SyncRepositoryOutput
- type SyncRepositoryParams
- type TagSortOption
- type TreeNode
- type TreeNodeMode
- type TreeNodeType
- type UpdateDefaultBranchParams
- type UpdateRefParams
- type WriteParams
Constants ¶
const ( EnvActorName = "GITFOX_HOOK_ACTOR_NAME" EnvActorEmail = "GITFOX_HOOK_ACTOR_EMAIL" //#nosec EnvRepoUID = "GITFOX_HOOK_REPO_UID" EnvRequestID = "GITFOX_HOOK_REQUEST_ID" )
const ( SortOrderDefault SortOrder = iota SortOrderAsc = iota SortOrderDesc )
const (
DefaultGitleaksIgnorePath = ".gitleaksignore"
)
const (
// TODO: this should be configurable
FileTransferChunkSize = 1024
)
const (
ReposGraveyardSubdirName = "cleanup"
)
const (
RequestIDNone string = "git_none"
)
Variables ¶
var (
ErrNoParamsProvided = errors.InvalidArgument("params not provided")
)
var WireSet = wire.NewSet( ProvideGITAdapter, ProvideService, )
WireSet provides a wire set for this package.
Functions ¶
func CommitMessage ¶
func CreateEnvironmentForPush ¶
func CreateEnvironmentForPush(ctx context.Context, writeRequest WriteParams) []string
ASSUMPTION: writeRequst and writeRequst.Actor is never nil.
func NewRepositoryUID ¶
func ProvideGITAdapter ¶
func RequestIDFrom ¶
RequestIDFrom retrieves the request id from the context. If no request id exists, RequestIDNone is returned.
func ValidateCommitSHA ¶
Types ¶
type ArchiveParams ¶
type ArchiveParams struct {
ReadParams
api.ArchiveParams
}
func (*ArchiveParams) Validate ¶
func (p *ArchiveParams) Validate() error
type BlameParams ¶
type BlameParams struct {
ReadParams
GitRef string
Path string
// LineFrom allows to restrict the blame output to only lines starting from the provided line number (inclusive).
// Optional, ignored if value is 0.
LineFrom int
// LineTo allows to restrict the blame output to only lines up to the provided line number (inclusive).
// Optional, ignored if value is 0.
LineTo int
}
func (*BlameParams) Validate ¶
func (params *BlameParams) Validate() error
type BlamePart ¶
type BlamePart struct {
Commit *Commit `json:"commit"`
Lines []string `json:"lines"`
Previous *BlamePartPrevious `json:"previous,omitempty"`
}
type BlamePartPrevious ¶
type BranchSortOption ¶
type BranchSortOption int
const ( BranchSortOptionDefault BranchSortOption = iota BranchSortOptionName BranchSortOptionDate )
type CommitDivergence ¶
type CommitDivergence struct {
// Ahead is the count of commits the 'From' ref is ahead of the 'To' ref.
Ahead int32
// Behind is the count of commits the 'From' ref is behind the 'To' ref.
Behind int32
}
CommitDivergence contains the information of the count of converging commits between two refs.
type CommitDivergenceRequest ¶
type CommitDivergenceRequest struct {
// From is the ref from which the counting of the diverging commits starts.
From string
// To is the ref at which the counting of the diverging commits ends.
To string
}
CommitDivergenceRequest contains the refs for which the converging commits should be counted.
type CommitFileAction ¶
type CommitFileAction struct {
Action FileAction
Path string
Payload []byte
SHA sha.SHA
}
CommitFileAction holds file operation data.
type CommitFileStats ¶
type CommitFilesParams ¶
type CommitFilesParams struct {
WriteParams
Title string // Deprecated
Message string
Branch string
NewBranch string
Actions []CommitFileAction
// Committer overwrites the git committer used for committing the files
// (optional, default: actor)
Committer *Identity
// CommitterDate overwrites the git committer date used for committing the files
// (optional, default: current time on server)
CommitterDate *time.Time
// Author overwrites the git author used for committing the files
// (optional, default: committer)
Author *Identity
// AuthorDate overwrites the git author date used for committing the files
// (optional, default: committer date)
AuthorDate *time.Time
}
CommitFilesParams holds the data for file operations.
func (*CommitFilesParams) Validate ¶
func (p *CommitFilesParams) Validate() error
type CommitFilesResponse ¶
type CommitNumStatsOutput ¶
type CommitNumStatsOutput struct {
Changes []*api.CommitChangeLines
}
type CountCommitsOutput ¶
type CountCommitsOutput struct {
CommitStats []types.CommitCount
Total int
AuthorCount map[string]int
}
type CountCommitsParams ¶
type CountCommitsParams struct {
ReadParams
// GitREF is a git reference (branch / tag / commit SHA)
GitREF string
// Since allows to filter for commits since the provided
Since string
// Until allows to filter for commits until the provided
Until string
// Committer allows to filter for commits based on the committer - Optional, ignored if string is empty.
Committer string
}
type CountCommitsShortstatOutput ¶
type CountCommitsShortstatOutput struct {
CommitStats []types.CommitCount
Total int
AuthorCount map[string]types.CommitCountData
}
type CreateBranchOutput ¶
type CreateBranchOutput struct {
Branch Branch
}
type CreateBranchParams ¶
type CreateBranchParams struct {
WriteParams
// BranchName is the name of the branch
BranchName string
// Target is a git reference (branch / tag / commit SHA)
Target string
}
type CreateCommitTagOutput ¶
type CreateCommitTagOutput struct {
CommitTag
}
type CreateCommitTagParams ¶
type CreateCommitTagParams struct {
WriteParams
Name string
// Target is the commit (or points to the commit) the new tag will be pointing to.
Target string
// Message is the optional message the tag will be created with - if the message is empty
// the tag will be lightweight, otherwise it'll be annotated
Message string
// Tagger overwrites the git author used in case the tag is annotated
// (optional, default: actor)
Tagger *Identity
// TaggerDate overwrites the git author date used in case the tag is annotated
// (optional, default: current time on server)
TaggerDate *time.Time
}
func (*CreateCommitTagParams) Validate ¶
func (p *CreateCommitTagParams) Validate() error
type CreateRepositoryOutput ¶
type CreateRepositoryOutput struct {
UID string
}
type CreateRepositoryParams ¶
type CreateRepositoryParams struct {
// Create operation is different from all (from user side), as UID doesn't exist yet.
// Only take actor and envars as input and create WriteParams manually
RepoUID string
Actor Identity
EnvVars map[string]string
DefaultBranch string
Files []File
// Committer overwrites the git committer used for committing the files
// (optional, default: actor)
Committer *Identity
// CommitterDate overwrites the git committer date used for committing the files
// (optional, default: current time on server)
CommitterDate *time.Time
// Author overwrites the git author used for committing the files
// (optional, default: committer)
Author *Identity
// AuthorDate overwrites the git author date used for committing the files
// (optional, default: committer date)
AuthorDate *time.Time
Mirror bool
}
func (*CreateRepositoryParams) Validate ¶
func (p *CreateRepositoryParams) Validate() error
type DeleteBranchParams ¶
type DeleteBranchParams struct {
WriteParams
// BranchName is the name of the branch
BranchName string
SHA string
}
type DeleteRefParams ¶
type DeleteRefParams struct {
ReadParams
Name string
}
func (*DeleteRefParams) Validate ¶
func (p *DeleteRefParams) Validate() error
type DeleteRepositoryParams ¶
type DeleteRepositoryParams struct {
WriteParams
}
type DeleteTagParams ¶
type DeleteTagParams struct {
WriteParams
Name string
}
func (DeleteTagParams) Validate ¶
func (p DeleteTagParams) Validate() error
type DiffCutOutput ¶
type DiffCutOutput struct {
Header HunkHeader
LinesHeader string
Lines []string
MergeBaseSHA sha.SHA
}
type DiffCutParams ¶
type DiffFileHeader ¶
type DiffFileHunkHeaders ¶
type DiffFileHunkHeaders struct {
FileHeader DiffFileHeader
HunkHeaders []HunkHeader
}
type DiffFileNamesOutput ¶
type DiffFileNamesOutput struct {
Files []string
}
type DiffFilesParams ¶
type DiffFilesParams struct {
ReadParams
SourceCommitSHA string
TargetCommitSHA string
DiffUnified int // 默认会在变更周围显示三行上下文
ExcludeList []string
}
type DiffParams ¶
type DiffParams struct {
ReadParams
BaseRef string
HeadRef string
MergeBase bool
IncludePatch bool
}
func (DiffParams) Validate ¶
func (p DiffParams) Validate() error
type DiffShortStatOutput ¶
type DiffStatsOutput ¶
type FileAction ¶
type FileAction string
const ( CreateAction FileAction = "CREATE" UpdateAction FileAction = "UPDATE" DeleteAction FileAction = "DELETE" MoveAction FileAction = "MOVE" PatchTextAction FileAction = "PATCH_TEXT" )
func (FileAction) Enum ¶
func (FileAction) Enum() []interface{}
type FileDiff ¶
type FileDiff struct {
SHA string `json:"sha"`
OldSHA string `json:"old_sha,omitempty"`
Path string `json:"path"`
OldPath string `json:"old_path,omitempty"`
Status enum.FileDiffStatus `json:"status"`
Additions int64 `json:"additions"`
Deletions int64 `json:"deletions"`
Changes int64 `json:"changes"`
Patch []byte `json:"patch,omitempty"`
IsBinary bool `json:"is_binary"`
IsSubmodule bool `json:"is_submodule"`
}
type FindOversizeFilesOutput ¶
type FindOversizeFilesOutput struct {
FileInfos []FileInfo
}
type FindOversizeFilesParams ¶
type GeneratePipelineParams ¶
type GeneratePipelineParams struct {
ReadParams
}
type GeneratePipelinesOutput ¶
type GeneratePipelinesOutput struct {
PipelineYAML []byte
}
type GetBlobOutput ¶
type GetBlobParams ¶
type GetBlobParams struct {
ReadParams
SHA string
SizeLimit int64
}
type GetBranchOutput ¶
type GetBranchOutput struct {
Branch Branch
}
type GetBranchParams ¶
type GetBranchParams struct {
ReadParams
// BranchName is the name of the branch
BranchName string
}
type GetCommitDivergencesOutput ¶
type GetCommitDivergencesOutput struct {
Divergences []api.CommitDivergence
}
type GetCommitDivergencesParams ¶
type GetCommitDivergencesParams struct {
ReadParams
MaxCount int32
Requests []CommitDivergenceRequest
}
type GetCommitOutput ¶
type GetCommitOutput struct {
Commit Commit `json:"commit"`
}
type GetCommitParams ¶
type GetCommitParams struct {
ReadParams
Revision string
}
type GetDefaultBranchOutput ¶
type GetDefaultBranchOutput struct {
// BranchName is the name of the branch (not the full reference).
BranchName string
}
type GetDefaultBranchParams ¶
type GetDefaultBranchParams struct {
ReadParams
}
type GetDiffHunkHeadersOutput ¶
type GetDiffHunkHeadersOutput struct {
Files []DiffFileHunkHeaders
}
type GetDiffHunkHeadersParams ¶
type GetDiffHunkHeadersParams struct {
ReadParams
SourceCommitSHA string
TargetCommitSHA string
}
type GetRefParams ¶
type GetRefParams struct {
ReadParams
Name string
Type enum.RefType
}
func (*GetRefParams) Validate ¶
func (p *GetRefParams) Validate() error
type GetRefResponse ¶
type GetRepositorySizeOutput ¶
type GetRepositorySizeOutput struct {
// Total size of the repository in KiB.
Size int64
}
type GetRepositorySizeParams ¶
type GetRepositorySizeParams struct {
ReadParams
}
type GetSubmoduleOutput ¶
type GetSubmoduleOutput struct {
Submodule Submodule
}
type GetSubmoduleParams ¶
type GetSubmoduleParams struct {
ReadParams
// GitREF is a git reference (branch / tag / commit SHA)
GitREF string
Path string
}
type GetTreeNodeOutput ¶
type GetTreeNodeParams ¶
type GetTreeNodeParams struct {
ReadParams
// GitREF is a git reference (branch / tag / commit SHA)
GitREF string
Path string
IncludeLatestCommit bool
}
type HashRepositoryOutput ¶
type HashRepositoryOutput struct {
Hash []byte
}
type HashRepositoryParams ¶
type HashRepositoryParams struct {
ReadParams
HashType hash.Type
AggregationType hash.AggregationType
}
func (*HashRepositoryParams) Validate ¶
func (p *HashRepositoryParams) Validate() error
type Hunk ¶
type Hunk struct {
HunkHeader
Lines []string
}
type HunkHeader ¶
func (*HunkHeader) IsValid ¶
func (h *HunkHeader) IsValid() bool
func (*HunkHeader) IsZero ¶
func (h *HunkHeader) IsZero() bool
func (*HunkHeader) String ¶
func (h *HunkHeader) String() string
type InfoRefsParams ¶
type InfoRefsParams struct {
ReadParams
Service string
Options []string // (key, value) pair
GitProtocol string
}
type Interface ¶
type Interface interface {
CreateRepository(ctx context.Context, params *CreateRepositoryParams) (*CreateRepositoryOutput, error)
DeleteRepository(ctx context.Context, params *DeleteRepositoryParams) error
GetTreeNode(ctx context.Context, params *GetTreeNodeParams) (*GetTreeNodeOutput, error)
ListTreeNodes(ctx context.Context, params *ListTreeNodeParams) (*ListTreeNodeOutput, error)
ListPaths(ctx context.Context, params *ListPathsParams) (*ListPathsOutput, error)
GetSubmodule(ctx context.Context, params *GetSubmoduleParams) (*GetSubmoduleOutput, error)
GetBlob(ctx context.Context, params *GetBlobParams) (*GetBlobOutput, error)
CreateBranch(ctx context.Context, params *CreateBranchParams) (*CreateBranchOutput, error)
CreateCommitTag(ctx context.Context, params *CreateCommitTagParams) (*CreateCommitTagOutput, error)
DeleteTag(ctx context.Context, params *DeleteTagParams) error
GetBranch(ctx context.Context, params *GetBranchParams) (*GetBranchOutput, error)
DeleteBranch(ctx context.Context, params *DeleteBranchParams) error
ListBranches(ctx context.Context, params *ListBranchesParams) (*ListBranchesOutput, error)
UpdateDefaultBranch(ctx context.Context, params *UpdateDefaultBranchParams) error
GetRef(ctx context.Context, params GetRefParams) (GetRefResponse, error)
DeleteRef(ctx context.Context, params DeleteRefParams) error
PathsDetails(ctx context.Context, params PathsDetailsParams) (PathsDetailsOutput, error)
Summary(ctx context.Context, params SummaryParams) (SummaryOutput, error)
// GetRepositorySize calculates the size of a repo in KiB.
GetRepositorySize(ctx context.Context, params *GetRepositorySizeParams) (*GetRepositorySizeOutput, error)
// UpdateRef creates, updates or deletes a git ref. If the OldValue is defined it must match the reference value
// prior to the call. To remove a ref use the zero ref as the NewValue. To require the creation of a new one and
// not update of an exiting one, set the zero ref as the OldValue.
UpdateRef(ctx context.Context, params UpdateRefParams) error
SyncRepository(ctx context.Context, params *SyncRepositoryParams) (*SyncRepositoryOutput, error)
MirrorSyncRepository(ctx context.Context, params *MirrorSyncParams) (bool, error)
MatchFiles(ctx context.Context, params *MatchFilesParams) (*MatchFilesOutput, error)
/*
* Commits service
*/
GetCommit(ctx context.Context, params *GetCommitParams) (*GetCommitOutput, error)
ListCommits(ctx context.Context, params *ListCommitsParams) (*ListCommitsOutput, error)
ListCommitSHAs(ctx context.Context, params *ListCommitsParams) ([]string, error)
ListCommitTags(ctx context.Context, params *ListCommitTagsParams) (*ListCommitTagsOutput, error)
CountCommits(ctx context.Context, params *CountCommitsParams) (*CountCommitsOutput, error)
CountCommitsWithShortstat(ctx context.Context, params *CountCommitsParams) (*CountCommitsShortstatOutput, error)
GetCommitDivergences(ctx context.Context, params *GetCommitDivergencesParams) (*GetCommitDivergencesOutput, error)
CommitFiles(ctx context.Context, params *CommitFilesParams) (CommitFilesResponse, error)
MergeBase(ctx context.Context, params MergeBaseParams) (MergeBaseOutput, error)
IsAncestor(ctx context.Context, params IsAncestorParams) (IsAncestorOutput, error)
FindOversizeFiles(
ctx context.Context,
params *FindOversizeFilesParams,
) (*FindOversizeFilesOutput, error)
/*
* Git Cli Service
*/
GetInfoRefs(ctx context.Context, w io.Writer, params *InfoRefsParams) error
ServicePack(ctx context.Context, params *ServicePackParams) error
/*
* Diff services
*/
RawDiff(ctx context.Context, w io.Writer, in *DiffParams, files ...api.FileDiffRequest) error
Diff(ctx context.Context, in *DiffParams, files ...api.FileDiffRequest) (<-chan *FileDiff, <-chan error)
DiffFileNames(ctx context.Context, in *DiffParams) (DiffFileNamesOutput, error)
ReceiveDiffFileNames(ctx context.Context, params *DiffParams) (DiffFileNamesOutput, error)
ReceiveDiffSNumStatus(ctx context.Context, params *DiffParams) (CommitNumStatsOutput, error)
CommitDiff(ctx context.Context, params *GetCommitParams, w io.Writer) error
DiffShortStat(ctx context.Context, params *DiffParams) (DiffShortStatOutput, error)
DiffStats(ctx context.Context, params *DiffParams) (DiffStatsOutput, error)
ReceiveCommitNumStat(ctx context.Context, ref string, params *ReadParams) (CommitNumStatsOutput, error)
GetDiffHunkHeaders(ctx context.Context, params GetDiffHunkHeadersParams) (GetDiffHunkHeadersOutput, error)
DiffCut(ctx context.Context, params *DiffCutParams) (DiffCutOutput, error)
DiffFiles(ctx context.Context, params *DiffFilesParams) (string, error)
/*
* Merge services
*/
Merge(ctx context.Context, in *MergeParams) (MergeOutput, error)
/*
* Blame services
*/
Blame(ctx context.Context, params *BlameParams) (<-chan *BlamePart, <-chan error)
PushRemote(ctx context.Context, params *PushRemoteParams) error
GeneratePipeline(ctx context.Context, params *GeneratePipelineParams) (GeneratePipelinesOutput, error)
/*
* Secret Scanning service
*/
ScanSecrets(ctx context.Context, param *ScanSecretsParams) (*ScanSecretsOutput, error)
Archive(ctx context.Context, params ArchiveParams, w io.Writer) error
}
type IsAncestorOutput ¶
type IsAncestorOutput struct {
Ancestor bool
}
type IsAncestorParams ¶
type IsAncestorParams struct {
ReadParams
AncestorCommitSHA sha.SHA
DescendantCommitSHA sha.SHA
}
type ListBranchesOutput ¶
type ListBranchesOutput struct {
Branches []Branch
}
type ListBranchesParams ¶
type ListBranchesParams struct {
ReadParams
IncludeCommit bool
Query string
Sort BranchSortOption
Order SortOrder
Page int32
PageSize int32
}
type ListCommitTagsOutput ¶
type ListCommitTagsOutput struct {
Tags []CommitTag
}
type ListCommitTagsParams ¶
type ListCommitTagsParams struct {
ReadParams
IncludeCommit bool
Query string
Sort TagSortOption
Order SortOrder
Page int32
PageSize int32
}
type ListCommitsOutput ¶
type ListCommitsOutput struct {
Commits []Commit
RenameDetails []*RenameDetails
TotalCommits int
}
type ListCommitsParams ¶
type ListCommitsParams struct {
ReadParams
// GitREF is a git reference (branch / tag / commit SHA)
GitREF string
// After is a git reference (branch / tag / commit SHA)
// If provided, commits only up to that reference will be returned (exlusive)
After string
Page int32
Limit int32
Path string
// Since allows to filter for commits since the provided UNIX timestamp - Optional, ignored if value is 0.
Since int64
// Until allows to filter for commits until the provided UNIX timestamp - Optional, ignored if value is 0.
Until int64
// Committer allows to filter for commits based on the committer - Optional, ignored if string is empty.
Committer string
// Author allows to filter for commits based on the author - Optional, ignored if string is empty.
Author string
// IncludeStats allows to include information about inserted, deletions and status for changed files.
IncludeStats bool
// Regex allows to use regular expression in the Committer and Author fields
Regex bool
}
type ListPathsOutput ¶
type ListPathsParams ¶
type ListPathsParams struct {
ReadParams
// GitREF is a git reference (branch / tag / commit SHA)
GitREF string
IncludeDirectories bool
}
type ListTreeNodeOutput ¶
type ListTreeNodeOutput struct {
Nodes []TreeNode
}
type ListTreeNodeParams ¶
type ListTreeNodeParams struct {
ReadParams
// GitREF is a git reference (branch / tag / commit SHA)
GitREF string
Path string
FlattenDirectories bool
}
type MatchFilesOutput ¶
type MatchFilesOutput struct {
Files []api.FileContent
}
type MatchFilesParams ¶
type MatchFilesParams struct {
ReadParams
Ref string
DirPath string
Pattern string
MaxSize int
}
type MergeBaseOutput ¶
type MergeBaseParams ¶
type MergeBaseParams struct {
ReadParams
Ref1 string
Ref2 string
}
func (*MergeBaseParams) Validate ¶
func (p *MergeBaseParams) Validate() error
type MergeOutput ¶
type MergeOutput struct {
// BaseSHA is the sha of the latest commit on the base branch that was used for merging.
BaseSHA sha.SHA
// HeadSHA is the sha of the latest commit on the head branch that was used for merging.
HeadSHA sha.SHA
// MergeBaseSHA is the sha of the merge base of the HeadSHA and BaseSHA
MergeBaseSHA sha.SHA
// MergeSHA is the sha of the commit after merging HeadSHA with BaseSHA.
MergeSHA sha.SHA
CommitCount int
ChangedFileCount int
Additions int
Deletions int
ConflictFiles []string
}
MergeOutput is result object from merging and returns base, head and commit sha.
type MergeParams ¶
type MergeParams struct {
WriteParams
BaseSHA sha.SHA
BaseBranch string
// HeadRepoUID specifies the UID of the repo that contains the head branch (required for forking).
// WARNING: This field is currently not supported yet!
HeadRepoUID string
HeadBranch string
Title string // Deprecated
Message string
// Committer overwrites the git committer used for committing the files
// (optional, default: actor)
Committer *Identity
// CommitterDate overwrites the git committer date used for committing the files
// (optional, default: current time on server)
CommitterDate *time.Time
// Author overwrites the git author used for committing the files
// (optional, default: committer)
Author *Identity
// AuthorDate overwrites the git author date used for committing the files
// (optional, default: committer date)
AuthorDate *time.Time
RefType enum.RefType
RefName string
// HeadExpectedSHA is commit sha on the head branch, if HeadExpectedSHA is older
// than the HeadBranch latest sha then merge will fail.
HeadExpectedSHA sha.SHA
Force bool
DeleteHeadBranch bool
Method enum.MergeMethod
}
MergeParams is input structure object for merging operation.
func (*MergeParams) Validate ¶
func (p *MergeParams) Validate() error
type MirrorSyncParams ¶
type MirrorSyncParams struct {
ReadParams
Prune bool
}
type PathDetails ¶
type PathsDetailsOutput ¶
type PathsDetailsOutput struct {
Details []PathDetails
}
type PathsDetailsParams ¶
type PathsDetailsParams struct {
ReadParams
GitREF string
Paths []string
}
type PushRemoteParams ¶
type PushRemoteParams struct {
ReadParams
RemoteURL string
}
func (*PushRemoteParams) Validate ¶
func (p *PushRemoteParams) Validate() error
type ReadParams ¶
ReadParams contains the base parameters for read operations.
func CreateReadParams ¶
func CreateReadParams(repo Repository) ReadParams
CreateReadParams creates base read parameters for git read operations. IMPORTANT: repo is assumed to be not nil!
func (ReadParams) Validate ¶
func (p ReadParams) Validate() error
type RenameDetails ¶
type Repository ¶
type Repository interface {
GetGitUID() string
}
type ScanSecretsFinding ¶
type ScanSecretsFinding struct {
Description string `json:"description"`
StartLine int64 `json:"start_line"`
EndLine int64 `json:"end_line"`
StartColumn int64 `json:"start_column"`
EndColumn int64 `json:"end_column"`
Match string `json:"match"`
Secret string `json:"secret"`
File string `json:"file"`
SymlinkFile string `json:"symlink_file"`
Commit string `json:"commit"`
Entropy float64 `json:"entropy"`
Author string `json:"author"`
Email string `json:"email"`
Date string `json:"date"`
Message string `json:"message"`
Tags []string `json:"tags"`
RuleID string `json:"rule_id"`
// Fingerprint is the unique identifier of the secret that can be used in .gitleaksignore files.
Fingerprint string `json:"fingerprint"`
}
type ScanSecretsOutput ¶
type ScanSecretsOutput struct {
Findings []ScanSecretsFinding
}
type ScanSecretsParams ¶
type ScanSecretsParams struct {
ReadParams
BaseRev string // optional to scan for secrets on diff between baseRev and Rev
Rev string
GitleaksIgnorePath string // optional, keep empty to skip using .gitleaksignore file.
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) Blame ¶
Blame processes and streams the git blame output data. The function returns two channels: The data channel and the error channel. If any error happens during the operation it will be put to the error channel and the streaming will stop. Maximum of one error can be put on the channel.
func (*Service) CommitDiff ¶
func (*Service) CommitFiles ¶
func (s *Service) CommitFiles(ctx context.Context, params *CommitFilesParams) (CommitFilesResponse, error)
func (*Service) CountCommits ¶
func (s *Service) CountCommits(ctx context.Context, params *CountCommitsParams) (*CountCommitsOutput, error)
func (*Service) CountCommitsWithShortstat ¶
func (s *Service) CountCommitsWithShortstat(ctx context.Context, params *CountCommitsParams) (*CountCommitsShortstatOutput, error)
func (*Service) CreateBranch ¶
func (s *Service) CreateBranch(ctx context.Context, params *CreateBranchParams) (*CreateBranchOutput, error)
func (*Service) CreateCommitTag ¶
func (s *Service) CreateCommitTag(ctx context.Context, params *CreateCommitTagParams) (*CreateCommitTagOutput, error)
func (*Service) CreateRepository ¶
func (s *Service) CreateRepository( ctx context.Context, params *CreateRepositoryParams, ) (*CreateRepositoryOutput, error)
func (*Service) DeleteBranch ¶
func (s *Service) DeleteBranch(ctx context.Context, params *DeleteBranchParams) error
func (*Service) DeleteRef ¶
func (s *Service) DeleteRef(ctx context.Context, params DeleteRefParams) error
func (*Service) DeleteRepository ¶
func (s *Service) DeleteRepository(ctx context.Context, params *DeleteRepositoryParams) error
func (*Service) DeleteRepositoryBestEffort ¶
func (*Service) DeleteTag ¶
func (s *Service) DeleteTag(ctx context.Context, params *DeleteTagParams) error
func (*Service) Diff ¶
func (s *Service) Diff( ctx context.Context, params *DiffParams, files ...api.FileDiffRequest, ) (<-chan *FileDiff, <-chan error)
func (*Service) DiffCut ¶
func (s *Service) DiffCut(ctx context.Context, params *DiffCutParams) (DiffCutOutput, error)
DiffCut extracts diff snippet from a git diff hunk. The snippet is from the diff between the specified commit SHAs.
func (*Service) DiffFileNames ¶
func (s *Service) DiffFileNames(ctx context.Context, params *DiffParams) (DiffFileNamesOutput, error)
func (*Service) DiffShortStat ¶
func (s *Service) DiffShortStat(ctx context.Context, params *DiffParams) (DiffShortStatOutput, error)
DiffShortStat returns files changed, additions and deletions metadata.
func (*Service) DiffStats ¶
func (s *Service) DiffStats(ctx context.Context, params *DiffParams) (DiffStatsOutput, error)
func (*Service) FindOversizeFiles ¶
func (s *Service) FindOversizeFiles( ctx context.Context, params *FindOversizeFilesParams, ) (*FindOversizeFilesOutput, error)
func (*Service) GeneratePipeline ¶
func (s *Service) GeneratePipeline(ctx context.Context, params *GeneratePipelineParams, ) (GeneratePipelinesOutput, error)
func (*Service) GetBlob ¶
func (s *Service) GetBlob(ctx context.Context, params *GetBlobParams) (*GetBlobOutput, error)
func (*Service) GetBranch ¶
func (s *Service) GetBranch(ctx context.Context, params *GetBranchParams) (*GetBranchOutput, error)
func (*Service) GetCommit ¶
func (s *Service) GetCommit(ctx context.Context, params *GetCommitParams) (*GetCommitOutput, error)
func (*Service) GetCommitDivergences ¶
func (s *Service) GetCommitDivergences( ctx context.Context, params *GetCommitDivergencesParams, ) (*GetCommitDivergencesOutput, error)
func (*Service) GetDefaultBranch ¶
func (s *Service) GetDefaultBranch( ctx context.Context, params *GetDefaultBranchParams, ) (*GetDefaultBranchOutput, error)
GetDefaultBranch returns the default branch of the repo.
func (*Service) GetDiffHunkHeaders ¶
func (s *Service) GetDiffHunkHeaders( ctx context.Context, params GetDiffHunkHeadersParams, ) (GetDiffHunkHeadersOutput, error)
func (*Service) GetInfoRefs ¶
func (*Service) GetRef ¶
func (s *Service) GetRef(ctx context.Context, params GetRefParams) (GetRefResponse, error)
func (*Service) GetRepositorySize ¶
func (s *Service) GetRepositorySize( ctx context.Context, params *GetRepositorySizeParams, ) (*GetRepositorySizeOutput, error)
GetRepositorySize accumulates the sizes of counted Git objects.
func (*Service) GetSubmodule ¶
func (s *Service) GetSubmodule(ctx context.Context, params *GetSubmoduleParams) (*GetSubmoduleOutput, error)
func (*Service) GetTreeNode ¶
func (s *Service) GetTreeNode(ctx context.Context, params *GetTreeNodeParams) (*GetTreeNodeOutput, error)
func (*Service) HashRepository ¶
func (s *Service) HashRepository(ctx context.Context, params *HashRepositoryParams) (*HashRepositoryOutput, error)
func (*Service) IsAncestor ¶
func (s *Service) IsAncestor( ctx context.Context, params IsAncestorParams, ) (IsAncestorOutput, error)
func (*Service) ListBranches ¶
func (s *Service) ListBranches(ctx context.Context, params *ListBranchesParams) (*ListBranchesOutput, error)
func (*Service) ListCommitSHAs ¶
func (*Service) ListCommitTags ¶
func (s *Service) ListCommitTags( ctx context.Context, params *ListCommitTagsParams, ) (*ListCommitTagsOutput, error)
func (*Service) ListCommits ¶
func (s *Service) ListCommits(ctx context.Context, params *ListCommitsParams) (*ListCommitsOutput, error)
func (*Service) ListPaths ¶
func (s *Service) ListPaths(ctx context.Context, params *ListPathsParams) (*ListPathsOutput, error)
func (*Service) ListTreeNodes ¶
func (s *Service) ListTreeNodes(ctx context.Context, params *ListTreeNodeParams) (*ListTreeNodeOutput, error)
func (*Service) MatchFiles ¶
func (s *Service) MatchFiles(ctx context.Context, params *MatchFilesParams, ) (*MatchFilesOutput, error)
func (*Service) Merge ¶
func (s *Service) Merge(ctx context.Context, params *MergeParams) (MergeOutput, error)
Merge method executes git merge operation. Refs can be sha, branch or tag. Based on input params.RefType merge can do checking or final merging of two refs. some examples:
params.RefType = Undefined -> discard merge commit (only performs a merge check). params.RefType = Raw and params.RefName = refs/pull/1/ref will push to refs/pullreq/1/ref params.RefType = RefTypeBranch and params.RefName = "somebranch" -> merge and push to refs/heads/somebranch params.RefType = RefTypePullReqHead and params.RefName = "1" -> merge and push to refs/pullreq/1/head params.RefType = RefTypePullReqMerge and params.RefName = "1" -> merge and push to refs/pullreq/1/merge
There are cases when you want to block merging and for that you will need to provide params.HeadExpectedSHA which will be compared with the latest sha from head branch if they are not the same error will be returned.
func (*Service) MergeBase ¶
func (s *Service) MergeBase( ctx context.Context, params MergeBaseParams, ) (MergeBaseOutput, error)
func (*Service) MirrorSyncRepository ¶
func (*Service) PathsDetails ¶
func (s *Service) PathsDetails(ctx context.Context, params PathsDetailsParams) (PathsDetailsOutput, error)
func (*Service) PushRemote ¶
func (s *Service) PushRemote(ctx context.Context, params *PushRemoteParams) error
func (*Service) RawDiff ¶
func (s *Service) RawDiff( ctx context.Context, out io.Writer, params *DiffParams, files ...api.FileDiffRequest, ) error
func (*Service) ReceiveCommitNumStat ¶
func (s *Service) ReceiveCommitNumStat(ctx context.Context, ref string, params *ReadParams) (CommitNumStatsOutput, error)
func (*Service) ReceiveDiffFileNames ¶
func (s *Service) ReceiveDiffFileNames(ctx context.Context, params *DiffParams) (DiffFileNamesOutput, error)
func (*Service) ReceiveDiffSNumStatus ¶
func (s *Service) ReceiveDiffSNumStatus(ctx context.Context, params *DiffParams) (CommitNumStatsOutput, error)
func (*Service) ScanSecrets ¶
func (s *Service) ScanSecrets(ctx context.Context, params *ScanSecretsParams) (*ScanSecretsOutput, error)
func (*Service) ServicePack ¶
func (s *Service) ServicePack(ctx context.Context, params *ServicePackParams) error
func (*Service) Summary ¶
func (s *Service) Summary( ctx context.Context, params SummaryParams, ) (SummaryOutput, error)
func (*Service) SyncRepository ¶
func (s *Service) SyncRepository( ctx context.Context, params *SyncRepositoryParams, ) (*SyncRepositoryOutput, error)
func (*Service) UpdateDefaultBranch ¶
func (s *Service) UpdateDefaultBranch( ctx context.Context, params *UpdateDefaultBranchParams, ) error
UpdateDefaultBranch updates the default branch of the repo.
type ServicePackParams ¶
type ServicePackParams struct {
*ReadParams
*WriteParams
api.ServicePackOptions
}
func (*ServicePackParams) Validate ¶
func (p *ServicePackParams) Validate() error
type StreamReader ¶
type StreamReader[T any] struct { // contains filtered or unexported fields }
StreamReader is a helper utility to ease reading from streaming channel pair (the data and the error channel).
func NewStreamReader ¶
func NewStreamReader[T any](chData <-chan T, chErr <-chan error) *StreamReader[T]
NewStreamReader creates new StreamReader.
func (*StreamReader[T]) Next ¶
func (str *StreamReader[T]) Next() (T, error)
Next returns the next element or error. In case the end has been reached, an io.EOF is returned.
type SummaryOutput ¶
type SummaryParams ¶
type SummaryParams struct {
ReadParams
}
type SyncRepositoryOutput ¶
type SyncRepositoryOutput struct {
DefaultBranch string
}
type SyncRepositoryParams ¶
type SyncRepositoryParams struct {
WriteParams
Source string
CreateIfNotExists bool
// RefSpecs [OPTIONAL] allows to override the refspecs that are being synced from the remote repository.
// By default all references present on the remote repository will be fetched (including scm internal ones).
RefSpecs []string
// DefaultBranch [OPTIONAL] allows to override the default branch of the repository.
// If empty, the default branch will be set to match the remote repository's default branch.
// WARNING: If the remote repo is empty and no value is provided, an api.ErrNoDefaultBranch error is returned.
DefaultBranch string
}
type TagSortOption ¶
type TagSortOption int
const ( TagSortOptionDefault TagSortOption = iota TagSortOptionName TagSortOptionDate )
type TreeNode ¶
type TreeNode struct {
Type TreeNodeType
Mode TreeNodeMode
SHA string // TODO: make sha.SHA
Name string
Path string
}
type TreeNodeMode ¶
type TreeNodeMode string
TreeNodeMode specifies the different modes of a node in a git tree. IMPORTANT: has to be consistent with rpc.TreeNodeMode (proto).
const ( TreeNodeModeFile TreeNodeMode = "file" TreeNodeModeSymlink TreeNodeMode = "symlink" TreeNodeModeExec TreeNodeMode = "exec" TreeNodeModeTree TreeNodeMode = "tree" TreeNodeModeCommit TreeNodeMode = "commit" )
type TreeNodeType ¶
type TreeNodeType string
TreeNodeType specifies the different types of nodes in a git tree. IMPORTANT: has to be consistent with rpc.TreeNodeType (proto).
const ( TreeNodeTypeTree TreeNodeType = "tree" TreeNodeTypeBlob TreeNodeType = "blob" TreeNodeTypeCommit TreeNodeType = "commit" )
type UpdateDefaultBranchParams ¶
type UpdateDefaultBranchParams struct {
WriteParams
// BranchName is the name of the branch (not the full reference).
BranchName string
}
type UpdateRefParams ¶
type UpdateRefParams struct {
WriteParams
Type enum.RefType
Name string
// NewValue specified the new value the reference should point at.
// An empty value will lead to the deletion of the branch.
NewValue sha.SHA
// OldValue is an optional value that can be used to ensure that the reference
// is updated iff its current value is matching the provided value.
OldValue sha.SHA
}
Source Files
¶
- blame.go
- blob.go
- branch.go
- commit.go
- commit_gitfox.go
- common.go
- context.go
- diff.go
- env.go
- errors.go
- hunk.go
- interface.go
- kuberesolver.go
- mapping.go
- match_files.go
- merge.go
- mirror.go
- operations.go
- params.go
- path.go
- pipeline.go
- push_remote.go
- ref.go
- repo.go
- scan_secrets.go
- service.go
- service_pack.go
- sort.go
- stream.go
- submodule.go
- summary.go
- tag.go
- tree.go
- upload.go
- validate.go
- wire.go