git

package
v3.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanOnError

func CleanOnError(err *error, path string)

func CloneRepo

func CloneRepo(userInfo *url.Userinfo, gitUrl string, args ...string) (clonePath string, repo *git.Repository, err error)

func CloneRepoUsingSSH added in v3.8.0

func CloneRepoUsingSSH(gitUrl string, args ...string) (string, *git.Repository, error)

CloneRepoUsingUnauthenticated clones a repo with no authentication required.

func CloneRepoUsingToken

func CloneRepoUsingToken(token, gitUrl, user string, args ...string) (string, *git.Repository, error)

CloneRepoUsingToken clones a repo using a provided token.

func CloneRepoUsingUnauthenticated

func CloneRepoUsingUnauthenticated(url string, args ...string) (string, *git.Repository, error)

CloneRepoUsingUnauthenticated clones a repo with no authentication required.

func GenerateLink(repo, commit, file string) string

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

func PrepareRepo

func PrepareRepo(uriString string) (string, bool, error)

PrepareRepo clones a repo if possible and returns the cloned repo path.

func PrepareRepoSinceCommit added in v3.6.1

func PrepareRepoSinceCommit(uriString, commitHash string) (string, bool, error)

PrepareRepoSinceCommit clones a repo starting at the given commitHash and returns the cloned repo path.

func RepoFromPath

func RepoFromPath(path string) (*git.Repository, error)

func TryAdditionalBaseRefs

func TryAdditionalBaseRefs(repo *git.Repository, base string) (*plumbing.Hash, error)

TryAdditionalBaseRefs looks for additional possible base refs for a repo and returns a hash if found.

Types

type Git

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

func NewGit

func NewGit(sourceType sourcespb.SourceType, jobID, sourceID int64, sourceName string, verify bool, concurrency int,
	sourceMetadataFunc func(file, email, commit, timestamp, repository string, line int64) *source_metadatapb.MetaData,
) *Git

func (*Git) ScanCommits

func (s *Git) ScanCommits(repo *git.Repository, path string, scanOptions *ScanOptions, chunksChan chan *sources.Chunk) error

func (*Git) ScanRepo

func (s *Git) ScanRepo(_ context.Context, repo *git.Repository, repoPath string, scanOptions *ScanOptions, chunksChan chan *sources.Chunk) error

func (*Git) ScanUnstaged

func (s *Git) ScanUnstaged(repo *git.Repository, scanOptions *ScanOptions, chunksChan chan *sources.Chunk) error

type ScanOption

type ScanOption func(*ScanOptions)

func ScanOptionBaseHash

func ScanOptionBaseHash(hash 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
	LogOptions *git.LogOptions
}

func NewScanOptions

func NewScanOptions(options ...ScanOption) *ScanOptions

type Source

type Source struct {
	sources.Progress
	// contains filtered or unexported fields
}

func (*Source) Chunks

func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk) error

Chunks emits chunks of bytes over a channel.

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

func (s *Source) JobID() int64

func (*Source) SourceID

func (s *Source) SourceID() int64

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.

Jump to

Keyboard shortcuts

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