gitkit

package
v0.0.0-...-9888a1d Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractOwnerAndRepoName

func ExtractOwnerAndRepoName(url string) (owner string, repoName *string, err error)

func GetRootPathOfLocalGitRepo

func GetRootPathOfLocalGitRepo(startPath string) (rootPath string, found bool, err error)

func ListRemoteReferences

func ListRemoteReferences(repo *git.Repository) ([]*plumbing.Reference, error)

func OpenRepoInLocalPath

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

func ProcessAllCommits

func ProcessAllCommits[T SearchResult](path string,
	repo *git.Repository,
	searcher Searcher[T],
	mode Mode) ([]RepoResult[T], Stats, error)

func ProcessAllFiles

func ProcessAllFiles[T SearchResult](searcher Searcher[T], repo Repository) ([]RepoResult[T], Stats, error)

Types

type BranchResult

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

func (*BranchResult) FirstCommit

func (br *BranchResult) FirstCommit() []*object.Commit

func (*BranchResult) LastCommit

func (br *BranchResult) LastCommit() *object.Commit

func (*BranchResult) Name

func (br *BranchResult) Name() string

func (*BranchResult) OnTip

func (br *BranchResult) OnTip() bool

type GitHubClient

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

func NewAuthenticatedGitHubClient

func NewAuthenticatedGitHubClient(token string) *GitHubClient

func NewGitHubClient

func NewGitHubClient() *GitHubClient

func (*GitHubClient) CloneOrFetchRepo

func (gc *GitHubClient) CloneOrFetchRepo(url string, progressWriter *io.Writer, opts *GitHubOptions) (*GitHubResult, error)

func (*GitHubClient) CloneRepo

func (gc *GitHubClient) CloneRepo(url string, progressWriter *io.Writer, opts *GitHubOptions) (*GitHubResult, error)

func (*GitHubClient) FetchRepo

func (gc *GitHubClient) FetchRepo(url string, progressWriter *io.Writer, opts *GitHubOptions) (*GitHubResult, error)

func (*GitHubClient) GetGitHubOrganization

func (gc *GitHubClient) GetGitHubOrganization(org string) (info *github.Organization, found bool, err error)

func (*GitHubClient) GetGitHubRepo

func (gc *GitHubClient) GetGitHubRepo(owner string, repoName string) (info *github.Repository, found bool, err error)

func (*GitHubClient) GetGitHubUser

func (gc *GitHubClient) GetGitHubUser(user string) (info *github.User, found bool, err error)

func (*GitHubClient) GetRepositories

func (gc *GitHubClient) GetRepositories(url string) ([]string, error)

func (*GitHubClient) ListAllReposForOrg

func (gc *GitHubClient) ListAllReposForOrg(org string) ([]*github.Repository, error)

func (*GitHubClient) ListAllReposForUser

func (gc *GitHubClient) ListAllReposForUser(user string) ([]*github.Repository, error)

type GitHubOptions

type GitHubOptions struct {
	Depth int
	Bare  bool
}

type GitHubResult

type GitHubResult struct {
	GitCommand string
	RepoName   string
	RepoURL    string
	RepoPath   string
	Error      error
}

type Mode

type Mode string
const (
	ModeAllHistory  Mode = "all-history"
	ModeAllBranches Mode = "all-branches"
	ModeAllFiles    Mode = "all-files"
)

type ProcessedState

type ProcessedState[T SearchResult] struct {
	// contains filtered or unexported fields
}

func NewProcessedState

func NewProcessedState[T SearchResult]() *ProcessedState[T]

type RepoResult

type RepoResult[T SearchResult] struct {
	Path            string
	Results         []T
	Matches         map[T][]BranchResult
	DanglingCommits map[T]*object.Commit
	Tags            map[T][]*object.Tag
}

type RepoState

type RepoState struct {
	BlobMap        map[plumbing.Hash]*object.Blob
	TreeMap        map[plumbing.Hash]*object.Tree
	CommitMap      map[plumbing.Hash]*object.Commit
	TagMap         map[plumbing.Hash]*object.Tag
	TargetToTagMap map[plumbing.Hash][]*object.Tag
}

func LoadRepoState

func LoadRepoState(repo *git.Repository) *RepoState

type Repository

type Repository interface {
	OrganizationName() string
	RepositoryName() string
	LocalRootPath() string
	SubPath() *string
}

func GetAllReposForAllOrgs

func GetAllReposForAllOrgs(orgsDir string) ([]Repository, error)

func InferReposFromPath

func InferReposFromPath(path string) ([]Repository, error)

func NewRepo

func NewRepo(org string, repoName string, path string, subPath *string) Repository

type SearchResult

type SearchResult interface {
	comparable
	MatchId() string
	SearchTermId() string
}

type Searcher

type Searcher[T SearchResult] interface {
	Process(hash *plumbing.Hash, loadData func() []byte, path string) []T
}

type Stats

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

func (*Stats) DataLoadTime

func (s *Stats) DataLoadTime() int64

func (*Stats) ListFilesTime

func (s *Stats) ListFilesTime() int64

func (*Stats) NumFiles

func (s *Stats) NumFiles() uint64

func (*Stats) NumberOfBranches

func (s *Stats) NumberOfBranches() uint64

func (*Stats) QueryTime

func (s *Stats) QueryTime() int64

func (*Stats) Size

func (s *Stats) Size() uint64

type TreePath

type TreePath struct {
	TreeHash *plumbing.Hash
	Path     string
}

type TreeSearchResult

type TreeSearchResult[T SearchResult] struct {
	SearchResult T
	Path         string
}

type WorkerResult

type WorkerResult[T SearchResult] struct {
	Repo        Repository
	Ref         string
	RepoResults []RepoResult[T]
}

type WorkerStats

type WorkerStats struct {
	// contains filtered or unexported fields
}
func Search[T SearchResult](repos []Repository,
	newSearcher func(Repository) Searcher[T],
	mode Mode,
	concurrency int) (chan WorkerResult[T], *WorkerStats)

func (*WorkerStats) DataLoadTime

func (ws *WorkerStats) DataLoadTime() int64

func (*WorkerStats) ListFilesTime

func (ws *WorkerStats) ListFilesTime() int64

func (*WorkerStats) NumberOfBranches

func (ws *WorkerStats) NumberOfBranches() uint64

func (*WorkerStats) NumberOfFiles

func (ws *WorkerStats) NumberOfFiles() uint64

func (*WorkerStats) NumberOfRepos

func (ws *WorkerStats) NumberOfRepos() int

func (*WorkerStats) QueryTime

func (ws *WorkerStats) QueryTime() int64

func (*WorkerStats) TotalFileSize

func (ws *WorkerStats) TotalFileSize() uint64

type WrappedSearchResult

type WrappedSearchResult[T SearchResult] struct {
	SearchResult *TreeSearchResult[T]
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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