codehost

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultHTTPTimeout = 30 * time.Second

DefaultHTTPTimeout is the default timeout for HTTP requests to code hosts.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitbucketClient

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

BitbucketClient implements Client for Bitbucket Cloud.

func NewBitbucketClient

func NewBitbucketClient(token string) *BitbucketClient

NewBitbucketClient creates a new Bitbucket Cloud client. token should be in format "username:app_password" or just the app password.

func NewBitbucketServerClient

func NewBitbucketServerClient(baseURL, token string) *BitbucketClient

NewBitbucketServerClient creates a Bitbucket Server (self-hosted) client.

func (*BitbucketClient) CreateMergeRequest

func (c *BitbucketClient) CreateMergeRequest(
	ctx context.Context,
	repo, title, description, sourceBranch, targetBranch string,
) (*MergeRequest, error)

CreateMergeRequest creates a pull request on Bitbucket.

func (*BitbucketClient) GetCloneURL

func (c *BitbucketClient) GetCloneURL(repo string) string

GetCloneURL returns the clone URL for a repository.

func (*BitbucketClient) GetRepository

func (c *BitbucketClient) GetRepository(ctx context.Context, name string) (*Repository, error)

GetRepository gets a specific repository.

func (*BitbucketClient) ListRepositories

func (c *BitbucketClient) ListRepositories(ctx context.Context) ([]Repository, error)

ListRepositories lists all accessible repositories.

func (*BitbucketClient) ValidateCredentials

func (c *BitbucketClient) ValidateCredentials(ctx context.Context) error

ValidateCredentials checks if the credentials are valid. If no credentials provided, skips validation (for public repo access).

type Client

type Client interface {
	ValidateCredentials(ctx context.Context) error
	ListRepositories(ctx context.Context) ([]Repository, error)
	GetRepository(ctx context.Context, name string) (*Repository, error)
	CreateMergeRequest(
		ctx context.Context,
		repo, title, description, sourceBranch, targetBranch string,
	) (*MergeRequest, error)
	GetCloneURL(repo string) string
}

Client interface for code host operations.

func NewClient

func NewClient(hostType, baseURL, token string) (Client, error)

NewClient creates a code host client based on type.

type GitHubClient

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

GitHubClient implements Client for GitHub.

func NewGitHubClient

func NewGitHubClient(token string) *GitHubClient

NewGitHubClient creates a new GitHub client.

func NewGitHubEnterpriseClient

func NewGitHubEnterpriseClient(baseURL, token string) *GitHubClient

NewGitHubEnterpriseClient creates a GitHub Enterprise client.

func (*GitHubClient) CreateMergeRequest

func (c *GitHubClient) CreateMergeRequest(
	ctx context.Context,
	repo, title, description, sourceBranch, targetBranch string,
) (*MergeRequest, error)

CreateMergeRequest creates a pull request on GitHub.

func (*GitHubClient) GetCloneURL

func (c *GitHubClient) GetCloneURL(repo string) string

GetCloneURL returns the clone URL for a repository.

func (*GitHubClient) GetRepository

func (c *GitHubClient) GetRepository(ctx context.Context, name string) (*Repository, error)

GetRepository gets a specific repository.

func (*GitHubClient) ListRepositories

func (c *GitHubClient) ListRepositories(ctx context.Context) ([]Repository, error)

ListRepositories lists all accessible repositories.

func (*GitHubClient) ValidateCredentials

func (c *GitHubClient) ValidateCredentials(ctx context.Context) error

ValidateCredentials checks if the token is valid by fetching the current user. If no token is provided, skips validation (for public repo access).

type GitLabClient

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

GitLabClient implements Client for GitLab.

func NewGitLabClient

func NewGitLabClient(baseURL, token string) *GitLabClient

NewGitLabClient creates a new GitLab client.

func (*GitLabClient) CreateMergeRequest

func (c *GitLabClient) CreateMergeRequest(
	ctx context.Context,
	repo, title, description, sourceBranch, targetBranch string,
) (*MergeRequest, error)

CreateMergeRequest creates a merge request on GitLab.

func (*GitLabClient) GetCloneURL

func (c *GitLabClient) GetCloneURL(repo string) string

GetCloneURL returns the clone URL for a repository.

func (*GitLabClient) GetRepository

func (c *GitLabClient) GetRepository(ctx context.Context, name string) (*Repository, error)

GetRepository gets a specific project.

func (*GitLabClient) ListRepositories

func (c *GitLabClient) ListRepositories(ctx context.Context) ([]Repository, error)

ListRepositories lists all accessible projects.

func (*GitLabClient) ValidateCredentials

func (c *GitLabClient) ValidateCredentials(ctx context.Context) error

ValidateCredentials checks if the token is valid by fetching the current user. If no token is provided, skips validation (for public repo access).

type GiteaClient

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

GiteaClient implements Client for Gitea.

func NewGiteaClient

func NewGiteaClient(baseURL, token string) *GiteaClient

NewGiteaClient creates a new Gitea client.

func (*GiteaClient) CreateMergeRequest

func (c *GiteaClient) CreateMergeRequest(
	ctx context.Context,
	repo, title, description, sourceBranch, targetBranch string,
) (*MergeRequest, error)

CreateMergeRequest creates a pull request on Gitea.

func (*GiteaClient) GetCloneURL

func (c *GiteaClient) GetCloneURL(repo string) string

GetCloneURL returns the clone URL for a repository.

func (*GiteaClient) GetRepository

func (c *GiteaClient) GetRepository(ctx context.Context, name string) (*Repository, error)

GetRepository gets a specific repository.

func (*GiteaClient) ListRepositories

func (c *GiteaClient) ListRepositories(ctx context.Context) ([]Repository, error)

ListRepositories lists all accessible repositories.

func (*GiteaClient) ValidateCredentials

func (c *GiteaClient) ValidateCredentials(ctx context.Context) error

ValidateCredentials checks if the token is valid by fetching the current user. If no token is provided, skips validation (for public repo access).

type MergeRequest

type MergeRequest struct {
	ID        int
	Number    int
	Title     string
	URL       string
	State     string
	CreatedAt time.Time
}

MergeRequest represents a merge/pull request.

type Repository

type Repository struct {
	Name          string
	FullName      string
	CloneURL      string
	DefaultBranch string
	Private       bool
	Archived      bool
}

Repository represents a repository from a code host.

Jump to

Keyboard shortcuts

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