github

package
v0.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package github provides functionality for interacting with GitHub repositories, including fetching release information, matching assets to specific requirements, and downloading files from repository releases. It supports authentication via GitHub tokens and provides utility functions for handling repository data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SplitName

func SplitName(name string) (parts [2]string, err error)

SplitName splits a full repository name in the format "owner/repo" into its owner and repo components. It returns an error if the input name is not in the correct format.

Types

type GitHub

type GitHub struct {
	Repo  string
	Owner string
	Token string `mask:"fixed"`

	// Data holds additional metadata related to the repository.
	Data common.Metadata `yaml:"-"`
	// contains filtered or unexported fields
}

GitHub represents a GitHub repository with optional authentication token and metadata.

func (*GitHub) Exe

func (g *GitHub) Exe() error

Exe sets the executable name in the metadata to the repository name.

func (*GitHub) Export

func (g *GitHub) Export() error

Export exports the latest stored release to a file.

func (*GitHub) Get

func (g *GitHub) Get(attribute string) string

Get retrieves a specific attribute from the GitHub repository's metadata.

func (*GitHub) Initialize

func (g *GitHub) Initialize(name string) error

Initialize populates the GitHub repository's owner and name from the given input.

func (*GitHub) Install

func (g *GitHub) Install(d common.InstallData) (output string, found file.File, err error)

Install downloads the asset from GitHub and returns the output, the found file, and any error encountered.

func (*GitHub) LatestVersion

func (g *GitHub) LatestVersion() (string, error)

LatestVersion fetches the latest release version of the GitHub repository.

func (*GitHub) LatestVersionFromExport

func (g *GitHub) LatestVersionFromExport() (string, error)

LatestVersionFromExport fetches the latest release version from the exported file.

func (*GitHub) MatchAssetsToRequirements

func (g *GitHub) MatchAssetsToRequirements(
	_ []string,
	version string,
	requirements match.Requirements,
) (string, error)

MatchAssetsToRequirements matches release assets to specific file extensions and requirements, returning the URL of the matched asset.

func (*GitHub) Path

func (g *GitHub) Path(_ string, extensions []string, version string, requirements match.Requirements) error

Path sets the download URL of the matched asset in the metadata, based on version, file extensions, and requirements.

func (*GitHub) PopulateOwnerAndRepo

func (g *GitHub) PopulateOwnerAndRepo(name string) error

PopulateOwnerAndRepo sets the Owner and Repo fields based on the given name. If Owner and Repo are already set, this method does nothing.

func (*GitHub) Version

func (g *GitHub) Version(_ string) error

Version fetches and sets the latest release version in the metadata.

Jump to

Keyboard shortcuts

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