Documentation
¶
Overview ¶
Package provider implements Git hosting provider interfaces for GitHub, GitLab, and Gerrit.
Index ¶
- func TestGitLabProviderAuthentication(t *testing.T)
- func TestGitLabProviderCreateFork(t *testing.T)
- func TestGitLabProviderListRepositories(t *testing.T)
- func TestGitLabProviderRateLimitHandling(t *testing.T)
- func TestNewGitLabProvider(t *testing.T)
- type Config
- type GerritAccount
- type GerritClone
- type GerritProject
- type GerritProvider
- func (g *GerritProvider) Close() error
- func (g *GerritProvider) CreateFork(_ context.Context, _ *Repository, _ string) (*Repository, error)
- func (g *GerritProvider) CreateOrganization(_ context.Context, _, _, _ string) (*Organization, error)
- func (g *GerritProvider) GetOrganization(ctx context.Context, orgName string) (*Organization, error)
- func (g *GerritProvider) ListRepositories(ctx context.Context, orgName string) ([]*Repository, error)
- func (g *GerritProvider) Name() string
- func (g *GerritProvider) ParseSource(source string) (*SourceInfo, error)
- func (g *GerritProvider) RepositoryExists(ctx context.Context, orgName, repoName string) (bool, error)
- func (g *GerritProvider) SyncRepository(_ context.Context, _ *Repository) error
- type GerritWebLink
- type GitHubProvider
- func (g *GitHubProvider) Close() error
- func (g *GitHubProvider) CreateFork(ctx context.Context, sourceRepo *Repository, targetOrg string) (*Repository, error)
- func (g *GitHubProvider) CreateOrganization(_ context.Context, _, _, _ string) (*Organization, error)
- func (g *GitHubProvider) GetOrganization(ctx context.Context, orgName string) (*Organization, error)
- func (g *GitHubProvider) ListRepositories(ctx context.Context, orgName string) ([]*Repository, error)
- func (g *GitHubProvider) Name() string
- func (g *GitHubProvider) ParseSource(source string) (*SourceInfo, error)
- func (g *GitHubProvider) RepositoryExists(ctx context.Context, orgName, repoName string) (bool, error)
- func (g *GitHubProvider) SyncRepository(ctx context.Context, repo *Repository) error
- type GitLabProvider
- func (g *GitLabProvider) Close() error
- func (g *GitLabProvider) CreateFork(ctx context.Context, sourceRepo *Repository, targetGroup string) (*Repository, error)
- func (g *GitLabProvider) CreateOrganization(ctx context.Context, groupName, displayName, description string) (*Organization, error)
- func (g *GitLabProvider) GetOrganization(ctx context.Context, groupName string) (*Organization, error)
- func (g *GitLabProvider) ListRepositories(ctx context.Context, groupName string) ([]*Repository, error)
- func (g *GitLabProvider) Name() string
- func (g *GitLabProvider) ParseSource(source string) (*SourceInfo, error)
- func (g *GitLabProvider) RepositoryExists(ctx context.Context, groupName, projectName string) (bool, error)
- func (g *GitLabProvider) SyncRepository(ctx context.Context, repo *Repository) error
- type Manager
- type Organization
- type Provider
- type RateLimitError
- type Repository
- type SourceInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestGitLabProviderAuthentication ¶
TestGitLabProviderAuthentication tests authentication handling for GitLab provider
func TestGitLabProviderCreateFork ¶
TestGitLabProviderCreateFork tests the CreateFork functionality for GitLab provider
func TestGitLabProviderListRepositories ¶
TestGitLabProviderListRepositories tests the ListRepositories functionality for GitLab provider
func TestGitLabProviderRateLimitHandling ¶
TestGitLabProviderRateLimitHandling tests rate limit handling for GitLab provider
func TestNewGitLabProvider ¶
TestNewGitLabProvider tests the creation of new GitLab provider instances
Types ¶
type Config ¶
type Config struct { GitHubToken string GitLabToken string GerritUsername string GerritPassword string GerritToken string }
Config holds configuration for provider authentication
type GerritAccount ¶
type GerritAccount struct { ID int `json:"_account_id"` Name string `json:"name,omitempty"` Email string `json:"email,omitempty"` Username string `json:"username,omitempty"` }
GerritAccount represents a Gerrit account
type GerritClone ¶
type GerritClone struct {
URL string `json:"url"`
}
GerritClone represents clone information for a Gerrit project
type GerritProject ¶
type GerritProject struct { ID string `json:"id"` Name string `json:"name"` Parent string `json:"parent,omitempty"` Description string `json:"description,omitempty"` State string `json:"state,omitempty"` Branches map[string]string `json:"branches,omitempty"` WebLinks []GerritWebLink `json:"web_links,omitempty"` CloneLinks map[string]GerritClone `json:"clone_links,omitempty"` }
GerritProject represents a Gerrit project
type GerritProvider ¶
type GerritProvider struct {
// contains filtered or unexported fields
}
GerritProvider implements the Provider interface for Gerrit
func NewGerritProvider ¶
func NewGerritProvider(baseURL, username, password string) (*GerritProvider, error)
NewGerritProvider creates a new Gerrit provider
func (*GerritProvider) Close ¶
func (g *GerritProvider) Close() error
Close performs cleanup operations
func (*GerritProvider) CreateFork ¶
func (g *GerritProvider) CreateFork(_ context.Context, _ *Repository, _ string) (*Repository, error)
CreateFork creates a new project based on an existing one (Gerrit doesn't have traditional forks)
func (*GerritProvider) CreateOrganization ¶
func (g *GerritProvider) CreateOrganization(_ context.Context, _, _, _ string) (*Organization, error)
CreateOrganization creates a new organization (not applicable for Gerrit)
func (*GerritProvider) GetOrganization ¶
func (g *GerritProvider) GetOrganization(ctx context.Context, orgName string) (*Organization, error)
GetOrganization retrieves Gerrit "organization" information (really just server info)
func (*GerritProvider) ListRepositories ¶
func (g *GerritProvider) ListRepositories(ctx context.Context, orgName string) ([]*Repository, error)
ListRepositories lists all projects in a Gerrit server
func (*GerritProvider) ParseSource ¶
func (g *GerritProvider) ParseSource(source string) (*SourceInfo, error)
ParseSource parses a Gerrit source URL or identifier
func (*GerritProvider) RepositoryExists ¶
func (g *GerritProvider) RepositoryExists(ctx context.Context, orgName, repoName string) (bool, error)
RepositoryExists checks if a project exists in Gerrit
func (*GerritProvider) SyncRepository ¶
func (g *GerritProvider) SyncRepository(_ context.Context, _ *Repository) error
SyncRepository synchronizes a repository (not applicable for Gerrit)
type GerritWebLink ¶
GerritWebLink represents a web link for a Gerrit project
type GitHubProvider ¶
type GitHubProvider struct {
// contains filtered or unexported fields
}
GitHubProvider implements the Provider interface for GitHub
func NewGitHubProvider ¶
func NewGitHubProvider(token, baseURL string) (*GitHubProvider, error)
NewGitHubProvider creates a new GitHub provider
func (*GitHubProvider) Close ¶
func (g *GitHubProvider) Close() error
Close performs cleanup operations
func (*GitHubProvider) CreateFork ¶
func (g *GitHubProvider) CreateFork(ctx context.Context, sourceRepo *Repository, targetOrg string) (*Repository, error)
CreateFork creates a fork of a repository in the target organization
func (*GitHubProvider) CreateOrganization ¶
func (g *GitHubProvider) CreateOrganization(_ context.Context, _, _, _ string) (*Organization, error)
CreateOrganization creates a new GitHub organization (not supported by GitHub API)
func (*GitHubProvider) GetOrganization ¶
func (g *GitHubProvider) GetOrganization(ctx context.Context, orgName string) (*Organization, error)
GetOrganization retrieves GitHub organization information
func (*GitHubProvider) ListRepositories ¶
func (g *GitHubProvider) ListRepositories(ctx context.Context, orgName string) ([]*Repository, error)
ListRepositories lists all repositories in a GitHub organization
func (*GitHubProvider) ParseSource ¶
func (g *GitHubProvider) ParseSource(source string) (*SourceInfo, error)
ParseSource parses a GitHub source URL or identifier
func (*GitHubProvider) RepositoryExists ¶
func (g *GitHubProvider) RepositoryExists(ctx context.Context, orgName, repoName string) (bool, error)
RepositoryExists checks if a repository exists in a GitHub organization
func (*GitHubProvider) SyncRepository ¶
func (g *GitHubProvider) SyncRepository(ctx context.Context, repo *Repository) error
SyncRepository synchronizes a forked repository with its upstream
type GitLabProvider ¶
type GitLabProvider struct {
// contains filtered or unexported fields
}
GitLabProvider implements the Provider interface for GitLab
func NewGitLabProvider ¶
func NewGitLabProvider(token, baseURL string) (*GitLabProvider, error)
NewGitLabProvider creates a new GitLab provider
func (*GitLabProvider) Close ¶
func (g *GitLabProvider) Close() error
Close performs cleanup operations
func (*GitLabProvider) CreateFork ¶
func (g *GitLabProvider) CreateFork(ctx context.Context, sourceRepo *Repository, targetGroup string) (*Repository, error)
CreateFork creates a fork of a project in the target group
func (*GitLabProvider) CreateOrganization ¶
func (g *GitLabProvider) CreateOrganization(ctx context.Context, groupName, displayName, description string) (*Organization, error)
CreateOrganization creates a new GitLab group
func (*GitLabProvider) GetOrganization ¶
func (g *GitLabProvider) GetOrganization(ctx context.Context, groupName string) (*Organization, error)
GetOrganization retrieves GitLab group information
func (*GitLabProvider) ListRepositories ¶
func (g *GitLabProvider) ListRepositories(ctx context.Context, groupName string) ([]*Repository, error)
ListRepositories lists all projects in a GitLab group
func (*GitLabProvider) ParseSource ¶
func (g *GitLabProvider) ParseSource(source string) (*SourceInfo, error)
ParseSource parses a GitLab source URL or identifier
func (*GitLabProvider) RepositoryExists ¶
func (g *GitLabProvider) RepositoryExists(ctx context.Context, groupName, projectName string) (bool, error)
RepositoryExists checks if a project exists in a GitLab group
func (*GitLabProvider) SyncRepository ¶
func (g *GitLabProvider) SyncRepository(ctx context.Context, repo *Repository) error
SyncRepository synchronizes a forked project with its upstream
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages multiple Git hosting providers
func NewProviderManager ¶
NewProviderManager creates a new provider manager
func (*Manager) GetProvider ¶
GetProvider returns a provider by name
func (*Manager) GetProviderForSource ¶
func (pm *Manager) GetProviderForSource(source string) (Provider, *SourceInfo, error)
GetProviderForSource determines and returns the appropriate provider for a source
func (*Manager) RegisterProvider ¶
RegisterProvider registers a provider with the manager
type Organization ¶
type Organization struct { ID string // Unique identifier Name string // Organization name DisplayName string // Display name Description string // Organization description URL string // Organization URL Type string // Organization type (user, organization, group, etc.) Metadata map[string]string // Provider-specific metadata }
Organization represents an organization/group from any Git hosting provider
type Provider ¶
type Provider interface { // Name returns the provider name (e.g., "github", "gitlab", "gerrit") Name() string // ParseSource parses a source URL/identifier and returns normalized components ParseSource(source string) (*SourceInfo, error) // GetOrganization retrieves organization information GetOrganization(ctx context.Context, orgName string) (*Organization, error) // ListRepositories lists all repositories in an organization ListRepositories(ctx context.Context, orgName string) ([]*Repository, error) // CreateFork creates a fork of a repository in the target organization CreateFork(ctx context.Context, sourceRepo *Repository, targetOrg string) (*Repository, error) // CreateOrganization creates a new organization (if supported) CreateOrganization(ctx context.Context, orgName, displayName, description string) (*Organization, error) // SyncRepository synchronizes a forked repository with its upstream SyncRepository(ctx context.Context, repo *Repository) error // RepositoryExists checks if a repository exists in an organization RepositoryExists(ctx context.Context, orgName, repoName string) (bool, error) // Close performs any cleanup operations Close() error }
Provider defines the interface for Git hosting providers
type RateLimitError ¶
RateLimitError represents a rate limiting error
func IsRateLimitError ¶
func IsRateLimitError(err error) (*RateLimitError, bool)
IsRateLimitError checks if an error is a rate limit error
func (*RateLimitError) Error ¶
func (e *RateLimitError) Error() string
type Repository ¶
type Repository struct { ID string // Unique identifier Name string // Repository name FullName string // Full name (e.g., "org/repo") CloneURL string // HTTPS clone URL SSHCloneURL string // SSH clone URL Description string // Repository description Private bool // Whether repository is private Fork bool // Whether repository is a fork Language string // Primary programming language Size int64 // Repository size in KB Stars int // Star count Forks int // Fork count CreatedAt string // Creation timestamp UpdatedAt string // Last update timestamp Metadata map[string]string // Provider-specific metadata Path string // Hierarchical path (for Gerrit nested projects) }
Repository represents a repository from any Git hosting provider
type SourceInfo ¶
type SourceInfo struct { Provider string // Provider name (github, gitlab, gerrit) Host string // Hostname Organization string // Organization/group name Path string // Additional path information IsSSH bool // Whether this is an SSH URL }
SourceInfo contains parsed information about a source
func ParseGenericSource ¶
func ParseGenericSource(source string) (*SourceInfo, error)
ParseGenericSource provides a generic source parser as fallback