Documentation ¶
Index ¶
- Constants
- func CleanOnError(err *error, path string)
- func CloneRepo(ctx context.Context, userInfo *url.Userinfo, gitUrl string, args ...string) (string, *git.Repository, error)
- func CloneRepoUsingSSH(ctx context.Context, gitUrl string, args ...string) (string, *git.Repository, error)
- func CloneRepoUsingToken(ctx context.Context, token, gitUrl, user string, args ...string) (string, *git.Repository, error)
- func CloneRepoUsingUnauthenticated(ctx context.Context, url string, args ...string) (string, *git.Repository, error)
- func GenerateLink(repo, commit, file string) string
- func GitCmdCheck() error
- func PrepareRepo(ctx context.Context, uriString string) (string, bool, error)
- func PrepareRepoSinceCommit(ctx context.Context, uriString, commitHash string) (string, bool, error)
- func RepoFromPath(path string) (*git.Repository, error)
- func TryAdditionalBaseRefs(repo *git.Repository, base string) (*plumbing.Hash, error)
- func UnmarshalUnit(data []byte) (sources.SourceUnit, error)
- type Git
- type ScanOption
- func ScanOptionBaseHash(hash string) ScanOption
- func ScanOptionExcludeGlobs(globs []string) ScanOption
- func ScanOptionFilter(filter *common.Filter) ScanOption
- func ScanOptionHeadCommit(hash string) ScanOption
- func ScanOptionLogOptions(logOptions *git.LogOptions) ScanOption
- func ScanOptionMaxDepth(maxDepth int64) ScanOption
- type ScanOptions
- type Source
- func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk) error
- func (s *Source) Init(aCtx context.Context, name string, jobId, sourceId int64, verify bool, ...) error
- func (s *Source) JobID() int64
- func (s *Source) SourceID() int64
- func (s *Source) Type() sourcespb.SourceType
- func (s *Source) UnmarshalSourceUnit(data []byte) (sources.SourceUnit, error)
- type SourceUnit
Constants ¶
const ( UnitRepo string = "repo" UnitDir string = "dir" )
Variables ¶
This section is empty.
Functions ¶
func CleanOnError ¶
func CloneRepoUsingSSH ¶ added in v3.8.0
func CloneRepoUsingSSH(ctx context.Context, gitUrl string, args ...string) (string, *git.Repository, error)
CloneRepoUsingSSH clones a repo using SSH.
func CloneRepoUsingToken ¶
func CloneRepoUsingToken(ctx context.Context, token, gitUrl, user string, args ...string) (string, *git.Repository, error)
CloneRepoUsingToken clones a repo using a provided token.
func CloneRepoUsingUnauthenticated ¶
func CloneRepoUsingUnauthenticated(ctx context.Context, url string, args ...string) (string, *git.Repository, error)
CloneRepoUsingUnauthenticated clones a repo with no authentication required.
func GenerateLink ¶
GenerateLink crafts a link to the specific file from a commit. This works in most major git providers (Github/Gitlab)
func GitCmdCheck ¶
func GitCmdCheck() error
GitCmdCheck checks if git is installed and meets 2.20.0<=x<3.0.0 version requirements.
func PrepareRepo ¶
PrepareRepo clones a repo if possible and returns the cloned repo path.
func PrepareRepoSinceCommit ¶ added in v3.6.1
func PrepareRepoSinceCommit(ctx context.Context, uriString, commitHash string) (string, bool, error)
PrepareRepoSinceCommit clones a repo starting at the given commitHash and returns the cloned repo path.
func RepoFromPath ¶
func TryAdditionalBaseRefs ¶
TryAdditionalBaseRefs looks for additional possible base refs for a repo and returns a hash if found.
func UnmarshalUnit ¶ added in v3.41.1
func UnmarshalUnit(data []byte) (sources.SourceUnit, error)
Helper function to unmarshal raw bytes into our SourceUnit struct.
Types ¶
type Git ¶
type Git struct {
// contains filtered or unexported fields
}
func (*Git) ScanCommits ¶
func (*Git) ScanStaged ¶ added in v3.28.5
func (s *Git) ScanStaged(ctx context.Context, repo *git.Repository, path string, scanOptions *ScanOptions, chunksChan chan *sources.Chunk) error
ScanStaged chunks staged changes.
type ScanOption ¶
type ScanOption func(*ScanOptions)
func ScanOptionBaseHash ¶
func ScanOptionBaseHash(hash string) ScanOption
func ScanOptionExcludeGlobs ¶ added in v3.31.0
func ScanOptionExcludeGlobs(globs []string) ScanOption
func ScanOptionFilter ¶
func ScanOptionFilter(filter *common.Filter) ScanOption
func ScanOptionHeadCommit ¶
func ScanOptionHeadCommit(hash string) ScanOption
func ScanOptionLogOptions ¶
func ScanOptionLogOptions(logOptions *git.LogOptions) ScanOption
func ScanOptionMaxDepth ¶
func ScanOptionMaxDepth(maxDepth int64) ScanOption
type ScanOptions ¶
type ScanOptions struct { Filter *common.Filter BaseHash string // When scanning a git.Log, this is the oldest/first commit. HeadHash string MaxDepth int64 ExcludeGlobs []string LogOptions *git.LogOptions }
func NewScanOptions ¶
func NewScanOptions(options ...ScanOption) *ScanOptions
type Source ¶
func (*Source) Init ¶
func (s *Source) Init(aCtx context.Context, name string, jobId, sourceId int64, verify bool, connection *anypb.Any, concurrency int) error
Init returns an initialized GitHub source.
func (*Source) Type ¶
func (s *Source) Type() sourcespb.SourceType
Type returns the type of source. It is used for matching source types in configuration and job input.
func (*Source) UnmarshalSourceUnit ¶ added in v3.41.1
func (s *Source) UnmarshalSourceUnit(data []byte) (sources.SourceUnit, error)
type SourceUnit ¶ added in v3.41.1
A git source unit can be two kinds of units: either a local directory path or a remote repository.
func (SourceUnit) SourceUnitID ¶ added in v3.41.1
func (u SourceUnit) SourceUnitID() string
Implement sources.SourceUnit interface.