github

package
v1.9.3-0...-3bfc8b0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 17 Imported by: 0

README

github

import "github.com/tagoro9/fotingo/internal/github"

Index

Variables

var ErrAuthRequired = errors.New("github authentication required; run `fotingo login` interactively")

var ErrOAuthClientIDMissing = errors.New("github oauth client id is missing in this build; use `fotingo login` with API token auth or rebuild with oauth ldflags")

func FetchLatestReleaseTag

func FetchLatestReleaseTag(ctx context.Context, client *http.Client, owner string, repo string) (string, error)

FetchLatestReleaseTag fetches the latest release tag for a public repository without requiring authentication.

type CreatePROptions

CreatePROptions contains the options for creating a pull request

type CreatePROptions struct {
    Title string
    Body  string
    Head  string
    Base  string
    Draft bool
}

type CreateReleaseOptions

CreateReleaseOptions contains the options for creating a release

type CreateReleaseOptions struct {
    TagName         string
    TargetCommitish string
    Name            string
    Body            string
    Draft           bool
    Prerelease      bool
}

type Github

type Github interface {
    auth.OauthService
    config.ConfigurableService
    // GetPullRequestUrl returns the URL of the pull request for current branch or an error if it can't be found
    GetPullRequestUrl() (string, error)
    // GetCurrentUser returns the information about the current authenticated user
    GetCurrentUser() (*hub.User, error)
    // CreatePullRequest creates a new pull request
    CreatePullRequest(opts CreatePROptions) (*PullRequest, error)
    // GetLabels returns all labels from the repository
    GetLabels() ([]Label, error)
    // AddLabelsToPR adds labels to a pull request
    AddLabelsToPR(prNumber int, labels []string) error
    // GetCollaborators returns repository collaborators for reviewer selection
    GetCollaborators() ([]User, error)
    // GetOrgMembers returns organization members for participant selection
    GetOrgMembers() ([]User, error)
    // GetTeams returns organization teams for team reviewer selection
    GetTeams() ([]Team, error)
    // RequestReviewers requests reviewers on a pull request
    RequestReviewers(prNumber int, reviewers []string, teamReviewers []string) error
    // AssignUsersToPR assigns users to a pull request
    AssignUsersToPR(prNumber int, assignees []string) error
    // DoesPRExistForBranch checks if a PR exists for a given branch
    DoesPRExistForBranch(branch string) (bool, *PullRequest, error)
    // CreateRelease creates a GitHub release
    CreateRelease(opts CreateReleaseOptions) (*Release, error)
}

func New
func New(git git.Git, cfg *viper.Viper) (Github, error)

func NewAuthOnly
func NewAuthOnly(cfg *viper.Viper) (Github, error)

func NewAuthOnlyWithOptions
func NewAuthOnlyWithOptions(cfg *viper.Viper, allowPrompt bool) (Github, error)

func NewWithHTTPClient
func NewWithHTTPClient(g git.Git, cfg *viper.Viper, httpClient *http.Client, baseURL string) (Github, error)

NewWithHTTPClient returns a new GitHub client using the provided HTTP client and base URL. This bypasses OAuth authentication and is intended for testing with mock servers.

func NewWithHTTPClientAndRepo
func NewWithHTTPClientAndRepo(g git.Git, cfg *viper.Viper, httpClient *http.Client, baseURL, owner, repo string) (Github, error)

NewWithHTTPClientAndRepo creates a GitHub client with explicit owner/repo, bypassing remote URL parsing.

func NewWithOptions
func NewWithOptions(git git.Git, cfg *viper.Viper, allowPrompt bool) (Github, error)

type GithubConfig

type GithubConfig struct {
    Token string
}

type Label

Label represents a GitHub label

type Label struct {
    Name        string
    Description string
    Color       string
}

type PullRequest

PullRequest represents a GitHub pull request

type PullRequest struct {
    Number  int
    URL     string
    HTMLURL string
}

type Release

Release represents a GitHub release

type Release struct {
    ID      int64
    TagName string
    Name    string
    URL     string
    HTMLURL string
}

type Team

Team represents a GitHub organization team.

type Team struct {
    Organization string
    Slug         string
    Name         string
    Description  string
}

func (Team) Canonical
func (t Team) Canonical() string

Canonical returns the canonical team identifier (<org>/<team-slug>).

type User

User represents a GitHub user

type User struct {
    Login string
    Name  string
}

Generated by gomarkdoc

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAuthRequired = errors.New("github authentication required; run `fotingo login` interactively")
View Source
var ErrOAuthClientIDMissing = errors.New("github oauth client id is missing in this build; use `fotingo login` with API token auth or rebuild with oauth ldflags")

Functions

func FetchLatestReleaseTag

func FetchLatestReleaseTag(ctx context.Context, client *http.Client, owner string, repo string) (string, error)

FetchLatestReleaseTag fetches the latest release tag for a public repository without requiring authentication.

Types

type CreatePROptions

type CreatePROptions struct {
	Title string
	Body  string
	Head  string
	Base  string
	Draft bool
}

CreatePROptions contains the options for creating a pull request

type CreateReleaseOptions

type CreateReleaseOptions struct {
	TagName         string
	TargetCommitish string
	Name            string
	Body            string
	Draft           bool
	Prerelease      bool
}

CreateReleaseOptions contains the options for creating a release

type Github

type Github interface {
	auth.OauthService
	config.ConfigurableService
	// GetPullRequestUrl returns the URL of the pull request for current branch or an error if it can't be found
	GetPullRequestUrl() (string, error)
	// GetCurrentUser returns the information about the current authenticated user
	GetCurrentUser() (*hub.User, error)
	// CreatePullRequest creates a new pull request
	CreatePullRequest(opts CreatePROptions) (*PullRequest, error)
	// GetLabels returns all labels from the repository
	GetLabels() ([]Label, error)
	// AddLabelsToPR adds labels to a pull request
	AddLabelsToPR(prNumber int, labels []string) error
	// GetCollaborators returns repository collaborators for reviewer selection
	GetCollaborators() ([]User, error)
	// GetOrgMembers returns organization members for participant selection
	GetOrgMembers() ([]User, error)
	// GetTeams returns organization teams for team reviewer selection
	GetTeams() ([]Team, error)
	// RequestReviewers requests reviewers on a pull request
	RequestReviewers(prNumber int, reviewers []string, teamReviewers []string) error
	// AssignUsersToPR assigns users to a pull request
	AssignUsersToPR(prNumber int, assignees []string) error
	// DoesPRExistForBranch checks if a PR exists for a given branch
	DoesPRExistForBranch(branch string) (bool, *PullRequest, error)
	// CreateRelease creates a GitHub release
	CreateRelease(opts CreateReleaseOptions) (*Release, error)
}

func New

func New(git git.Git, cfg *viper.Viper) (Github, error)

func NewAuthOnly

func NewAuthOnly(cfg *viper.Viper) (Github, error)

func NewAuthOnlyWithOptions

func NewAuthOnlyWithOptions(cfg *viper.Viper, allowPrompt bool) (Github, error)

func NewWithHTTPClient

func NewWithHTTPClient(g git.Git, cfg *viper.Viper, httpClient *http.Client, baseURL string) (Github, error)

NewWithHTTPClient returns a new GitHub client using the provided HTTP client and base URL. This bypasses OAuth authentication and is intended for testing with mock servers.

func NewWithHTTPClientAndRepo

func NewWithHTTPClientAndRepo(g git.Git, cfg *viper.Viper, httpClient *http.Client, baseURL, owner, repo string) (Github, error)

NewWithHTTPClientAndRepo creates a GitHub client with explicit owner/repo, bypassing remote URL parsing.

func NewWithOptions

func NewWithOptions(git git.Git, cfg *viper.Viper, allowPrompt bool) (Github, error)

type GithubConfig

type GithubConfig struct {
	Token string
}

type Label

type Label struct {
	Name        string
	Description string
	Color       string
}

Label represents a GitHub label

type PullRequest

type PullRequest struct {
	Number  int
	URL     string
	HTMLURL string
}

PullRequest represents a GitHub pull request

type Release

type Release struct {
	ID      int64
	TagName string
	Name    string
	URL     string
	HTMLURL string
}

Release represents a GitHub release

type Team

type Team struct {
	Organization string
	Slug         string
	Name         string
	Description  string
}

Team represents a GitHub organization team.

func (Team) Canonical

func (t Team) Canonical() string

Canonical returns the canonical team identifier (<org>/<team-slug>).

type User

type User struct {
	Login string
	Name  string
}

User represents a GitHub user

Directories

Path Synopsis
Package testutil provides mock HTTP server utilities for testing GitHub client code.
Package testutil provides mock HTTP server utilities for testing GitHub client code.

Jump to

Keyboard shortcuts

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