github

package
v0.0.0-...-9cff1c0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommitsHandler

func CommitsHandler(w http.ResponseWriter, r *http.Request)

CommitsHandler handles the API endpoint for fetching the latest and current commits

func FetchCommit

func FetchCommit(repo, gitRef string) (*github.RepositoryCommit, error)

FetchCommit fetches a specific commit by its Git reference

func FetchLatestCommit

func FetchLatestCommit(repo string) (*github.RepositoryCommit, error)

FetchLatestCommit fetches the latest commit from the repository

func GenerateAuthToken

func GenerateAuthToken(repo string) string

func GenerateJWT

func GenerateJWT(privateKey *rsa.PrivateKey) (string, error)

GenerateJWT generates a JWT for the GitHub App

func GetInstallationToken

func GetInstallationToken(jwtToken string, repo string) (string, error)

GetInstallationToken fetches an Installation Access Token

func LoadPrivateKey

func LoadPrivateKey(filePath string) (*rsa.PrivateKey, error)

LoadPrivateKey loads the RSA private key from the file

func NewGithubClient

func NewGithubClient(repo string) *github.Client

func ReleasesHandler

func ReleasesHandler(w http.ResponseWriter, r *http.Request)

ReleasesHandler handles the API endpoint for fetching releases from target repositories

Types

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

ErrorResponse represents an error message

type MergedCommits

type MergedCommits struct {
	Latest  *github.RepositoryCommit `json:"latest"`
	Current *github.RepositoryCommit `json:"current"`
}

type MergedReleases

type MergedReleases struct {
	Latest  *Release `json:"latest"`
	Current *Release `json:"current"`
}

type Release

type Release struct {
	TagName     string `json:"tag_name"`
	URL         string `json:"html_url"`
	Body        string `json:"body"`
	PublishedAt string `json:"published_at"`
	Author      struct {
		Login string `json:"login"`
	} `json:"author"`
}

type StandardizedEntity

type StandardizedEntity struct {
	Ref         string `json:"ref"`          // Commit SHA or Release Tag
	URL         string `json:"url"`          // Commit URL or Release URL
	Message     string `json:"message"`      // Commit Message or Release Body
	Author      string `json:"author"`       // Commit Author Login or Release Author Login
	PublishedAt string `json:"published_at"` // Commit Date or Release Published At
}

func StandardizeCommit

func StandardizeCommit(commit *github.RepositoryCommit) *StandardizedEntity

StandardizeCommit converts a RepositoryCommit into a StandardizedEntity

func StandardizeRelease

func StandardizeRelease(release *github.RepositoryRelease) *StandardizedEntity

StandardizeRelease converts a Release into a StandardizedEntity

type StandardizedOutput

type StandardizedOutput struct {
	Latest  *StandardizedEntity `json:"latest"`
	Current *StandardizedEntity `json:"current"`
}

Create a standardized struct for Commits and Releases

func FetchCommits

func FetchCommits(repo, gitRef string) (*StandardizedOutput, int, error)

FetchCommits fetches both the latest commit and the one matching the Git reference (gitRef)

func FetchReleases

func FetchReleases(repo, gitRef string) (*StandardizedOutput, error)

Jump to

Keyboard shortcuts

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