github

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

internal/github/client.go

Index

Constants

View Source
const GHTokenEnvVar = "GITHUB_TOKEN"

Variables

This section is empty.

Functions

func ParseGitHubRemote

func ParseGitHubRemote(remoteURL string) (owner, repo string, err error)

ParseGitHubRemote extracts the owner and repository name from a GitHub remote URL.

Types

type Client

type Client struct {
	*github.Client
	GraphQL *githubv4.Client
	// contains filtered or unexported fields
}

Client wraps the go-github clients for both REST and GraphQL APIs.

func NewClient

func NewClient(ctx context.Context, logger *slog.Logger, owner, repo string) (*Client, error)

NewClient creates a new GitHub client, authenticating using the GITHUB_TOKEN environment variable.

func (*Client) AddIssueToProject

func (c *Client) AddIssueToProject(ctx context.Context, projectID string, issueID string) error

AddIssueToProject adds an issue (by its GraphQL Node ID) to a project (by its GraphQL Node ID).

func (*Client) CreateRepo

func (c *Client) CreateRepo(
	ctx context.Context,
	owner, name, description string,
	isPrivate bool,
) (*github.Repository, error)

CreateRepo creates a new repository on GitHub for a specific owner (user or org).

func (*Client) GetAuthenticatedUserLogin

func (c *Client) GetAuthenticatedUserLogin(ctx context.Context) (string, error)

GetAuthenticatedUserLogin returns the login name of the user authenticated by the token.

func (*Client) GetProjectByNumber

func (c *Client) GetProjectByNumber(ctx context.Context, number int) (*ProjectWithID, error)

GetProjectByNumber fetches a single project by its number to get its GraphQL Node ID.

func (*Client) ListProjects

func (c *Client) ListProjects(ctx context.Context) ([]Project, error)

ListProjects fetches the first 100 GitHub Projects (V2) for the repository's owner.

func (*Client) UpdateBranchProtection

func (c *Client) UpdateBranchProtection(ctx context.Context, branch string, request github.ProtectionRequest) error

UpdateBranchProtection applies a set of protection rules to the client's configured branch.

type Project

type Project struct {
	Title  string
	Number int
	URL    string
}

Project represents a GitHub Project (V2) for listing.

type ProjectWithID

type ProjectWithID struct {
	ID     string
	Title  string
	Number int
	URL    string
}

ProjectWithID represents a GitHub Project (V2) with its GraphQL Node ID.

Jump to

Keyboard shortcuts

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