ghcrawl

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeSample

type CodeSample struct {
	Path    string
	Content string
}

CodeSample holds a source file's path and content.

type Comment

type Comment struct {
	Repo   string
	Author string
	Body   string
	URL    string
	Date   time.Time
}

Comment holds an issue or PR conversation comment.

type CommitData

type CommitData struct {
	SHA          string
	Message      string
	Date         time.Time
	Patch        string
	Additions    int
	Deletions    int
	FilesChanged int
}

CommitData holds a commit's metadata, optional diff patch, and change stats.

type CrawlResult

type CrawlResult struct {
	User           UserProfile
	Repos          []RepoData
	IssueComments  []Comment
	StarredRepos   []StarredRepo
	Gists          []GistData
	Orgs           []string
	AuthoredIssues []IssueData
	ExternalPRs    []PullRequestData
	Events         []EventData
	Discussions    []DiscussionData
	Projects       []ProjectData
}

CrawlResult holds all data collected from a user's GitHub activity.

func (*CrawlResult) TotalCommits

func (r *CrawlResult) TotalCommits() int

TotalCommits returns the sum of commits across all repos.

func (*CrawlResult) TotalDiscussions

func (r *CrawlResult) TotalDiscussions() int

func (*CrawlResult) TotalExternalPRs

func (r *CrawlResult) TotalExternalPRs() int

func (*CrawlResult) TotalGists

func (r *CrawlResult) TotalGists() int

func (*CrawlResult) TotalIssues

func (r *CrawlResult) TotalIssues() int

func (*CrawlResult) TotalProjects

func (r *CrawlResult) TotalProjects() int

func (*CrawlResult) TotalReleases

func (r *CrawlResult) TotalReleases() int

func (*CrawlResult) TotalReviews

func (r *CrawlResult) TotalReviews() int

TotalReviews returns the sum of review artifacts across all repos. It counts review summaries, line comments, and falls back to PR conversation comments when no richer review data exists for a repo.

func (*CrawlResult) TotalStarred

func (r *CrawlResult) TotalStarred() int

type Crawler

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

Crawler fetches a GitHub user's repositories, commits, PRs, and comments.

func NewCrawler

func NewCrawler(tokens []string, privateToken string, maxRepos int, exhaustive bool) *Crawler

NewCrawler returns a Crawler authenticated with the given tokens. maxRepos controls how many repos get deep-crawled (commits, PRs, code samples). privateToken is optional; when set it enables fetching private repos via the authenticated user's /user/repos endpoint.

func (*Crawler) Crawl

func (c *Crawler) Crawl(ctx context.Context, username string) (*CrawlResult, error)

Crawl collects activity data for the given GitHub user.

type DiscussionData

type DiscussionData struct {
	Repo      string
	Number    int
	Title     string
	Body      string
	Category  string
	Author    string
	URL       string
	CreatedAt time.Time
	Comments  []Comment
}

DiscussionData holds metadata for a GitHub discussion.

type EventData

type EventData struct {
	Type      string
	Repo      string
	CreatedAt time.Time
	Summary   string
}

EventData holds a single GitHub event from the user's activity timeline.

type GistData

type GistData struct {
	ID          string
	Description string
	Files       []GistFile
	Public      bool
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

GistData holds metadata for a user's gist.

type GistFile

type GistFile struct {
	Name     string
	Language string
	Content  string
}

GistFile holds the name and language of a single file within a gist.

type GraphQLPool

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

GraphQLPool distributes GraphQL requests across multiple authenticated clients.

func NewGraphQLPool

func NewGraphQLPool(tokens []string) *GraphQLPool

NewGraphQLPool creates a pool of GitHub GraphQL clients, one per token.

func (*GraphQLPool) Next

func (p *GraphQLPool) Next() *githubv4.Client

Next returns the next client in round-robin order.

type IssueData

type IssueData struct {
	Repo      string
	Number    int
	Title     string
	Body      string
	State     string
	Labels    []string
	CreatedAt time.Time
}

IssueData holds metadata for an issue authored by the user.

type ProjectData

type ProjectData struct {
	Title     string
	Body      string
	URL       string
	Public    bool
	CreatedAt time.Time
	ItemCount int
}

ProjectData holds metadata for a GitHub Projects v2 project.

type PullRequestData

type PullRequestData struct {
	Repo           string
	Number         int
	URL            string
	Title          string
	Body           string
	Author         string
	State          string
	Labels         []string
	Date           time.Time
	MergedAt       *time.Time
	ClosedAt       *time.Time
	Additions      int
	Deletions      int
	ChangedFiles   int
	ReviewDecision string
}

PullRequestData holds metadata for a pull request.

type ReleaseData

type ReleaseData struct {
	Repo      string
	TagName   string
	Name      string
	Body      string
	CreatedAt time.Time
}

ReleaseData holds metadata for a release authored by the user.

type RepoData

type RepoData struct {
	Name           string
	FullName       string
	Description    string
	Language       string
	Languages      map[string]int
	Stars          int
	Forks          int
	Topics         []string
	IsOwner        bool
	IsFork         bool
	Archived       bool
	License        string
	DefaultBranch  string
	OpenIssues     int
	CreatedAt      time.Time
	UpdatedAt      time.Time
	Commits        []CommitData
	PRs            []PullRequestData
	Reviews        []ReviewData
	ReviewComments []ReviewComment
	PRComments     []Comment
	CodeSamples    []CodeSample
	Releases       []ReleaseData
	WikiPages      []WikiPage
}

RepoData holds crawled data for a single repository.

type ReviewComment

type ReviewComment struct {
	Repo     string
	PRNumber int
	PRTitle  string
	PRAuthor string
	Body     string
	Path     string
	DiffHunk string
	URL      string
	Date     time.Time
}

ReviewComment holds a single PR review comment.

type ReviewData

type ReviewData struct {
	Repo               string
	PRNumber           int
	PRTitle            string
	PRAuthor           string
	Body               string
	State              string
	SubmittedAt        time.Time
	CommitID           string
	URL                string
	Labels             []string
	Additions          int
	Deletions          int
	ChangedFiles       int
	ReviewCommentCount int
}

ReviewData holds metadata for a submitted PR review.

type StarredRepo

type StarredRepo struct {
	Name        string
	FullName    string
	Description string
	Language    string
	Topics      []string
	Stars       int
}

StarredRepo holds metadata for a repository the user has starred.

type TokenPool

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

TokenPool distributes GitHub API requests across multiple authenticated clients using round-robin selection.

func NewTokenPool

func NewTokenPool(tokens []string) *TokenPool

NewTokenPool creates a pool of GitHub REST clients, one per token.

func (*TokenPool) Next

func (p *TokenPool) Next() *github.Client

Next returns the next client in round-robin order.

func (*TokenPool) Size

func (p *TokenPool) Size() int

Size returns the number of tokens in the pool.

type UserProfile

type UserProfile struct {
	Login           string
	Name            string
	Bio             string
	Company         string
	Location        string
	Blog            string
	Email           string
	TwitterUsername string
	Hireable        bool
	Followers       int
	Following       int
	PublicRepos     int
	CreatedAt       time.Time
	ProfileREADME   string
}

UserProfile holds GitHub profile information.

type WikiPage

type WikiPage struct {
	Repo    string
	Title   string
	Content string
}

WikiPage holds the title and content of a repository wiki page.

Jump to

Keyboard shortcuts

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