github

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	Name     string `json:"name"`
	Username string `json:"username"`
}

func (Author) AsUser

func (a Author) AsUser() User

type Changes

type Changes struct {
	Repository struct {
		Name struct {
			From string `json:"from"`
		} `json:"name"`
	} `json:"repository"`
}

type Client

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

func New

func New(log *slog.Logger, appInstallationID, appID, appPrivateKey, githubOrg string) Client

func (Client) FetchTeams

func (c Client) FetchTeams(teamsFilePath, reposBlocklistString, subscribeToOrg string) ([]Team, error)

func (Client) GetUserByEmail

func (c Client) GetUserByEmail(email string) (*User, error)

type Commit

type Commit struct {
	ID      string `json:"id"`
	Message string `json:"message"`
	URL     string `json:"url"`
	Author  Author `json:"author"`
}

type Config

type Config struct {
	ExternalContributorsChannel string           `yaml:"externalContributorsChannel"`
	Workflows                   Workflows        `yaml:"workflows"`
	SilenceDependabot           DependabotConfig `yaml:"silenceDependabot"`
	IgnoreRepositories          []string         `yaml:"ignoreRepositories"`
}

func (Config) ShouldSilenceDependabot

func (c Config) ShouldSilenceDependabot() bool

type DependabotConfig

type DependabotConfig string
const (
	DependabotConfigAlways DependabotConfig = "always"
)

type Event

type Event struct {
	Action              string       `json:"action"`
	Ref                 string       `json:"ref"`
	After               string       `json:"after"`
	Repository          Repository   `json:"repository"`
	Changes             Changes      `json:"changes"`
	Commits             []Commit     `json:"commits"`
	Compare             string       `json:"compare"`
	Issue               *Issue       `json:"issue"`
	PullRequest         *Issue       `json:"pull_request"`
	RepositoriesRemoved []Repository `json:"repositories_removed"`
	Sender              User         `json:"sender"`
	Team                *TeamEvent   `json:"team"`
	Workflow            *Workflow    `json:"workflow_run"`
}

func CreateEvent

func CreateEvent(body []byte) (Event, error)

func (Event) FindRepositoryName

func (e Event) FindRepositoryName() string

func (Event) IsFromDependabot

func (e Event) IsFromDependabot() bool

IsFromDependabot checks if the event is from Dependabot

type FailedJob

type FailedJob struct {
	Name string
	URL  string
	Step string
}

type Issue

type Issue struct {
	Action      string `json:"action"`
	Draft       bool   `json:"draft"`
	ID          int    `json:"id"`
	URL         string `json:"html_url"`
	Title       string `json:"title"`
	Body        string `json:"body"`
	Number      int    `json:"number"`
	State       string `json:"state"`
	StateReason string `json:"state_reason"`
	Merged      bool   `json:"merged"`
	User        User   `json:"user"`
}

Issue is a struct for issues and pull requests Every pull request is an issue, but not every issue is a pull request

type Repository

type Repository struct {
	Name          string `json:"name"`
	FullName      string `json:"full_name"`
	URL           string `json:"html_url"`
	DefaultBranch string `json:"default_branch"`
	RoleName      string `json:"role_name"`
}

func (Repository) ToSlack

func (r Repository) ToSlack() string

ToSlack returns a formatted string for Slack If the URL is empty, it returns the repository name If the URL is not empty, it returns <URL|Name>

type SlackChannels

type SlackChannels struct {
	Commits      string `yaml:"commits"`
	Issues       string `yaml:"issues"`
	PullRequests string `yaml:"pulls"`
	Workflows    string `yaml:"workflows"`
}

type Team

type Team struct {
	Name          string
	Repositories  []string
	Members       []User
	SlackChannels SlackChannels `yaml:",inline"`
	Config        Config        `yaml:"config"`
}

func (*Team) AddRepository

func (t *Team) AddRepository(repo string)

func (*Team) GetMemberByName

func (t *Team) GetMemberByName(name string) (User, bool)

func (*Team) IsExternalContributor

func (t *Team) IsExternalContributor(user User) bool

IsExternalContributor checks if a user is an external contributor to the team. Bot users are not considered external contributors.

func (*Team) IsMember

func (t *Team) IsMember(user string) bool

func (*Team) RemoveRepository

func (t *Team) RemoveRepository(remove string)

type TeamEvent

type TeamEvent struct {
	Name string `json:"name"`
	URL  string `json:"html_url"`
}

type User

type User struct {
	Name  string
	Login string `json:"login"`
	Type  string `json:"type"`
	URL   string `json:"html_url"`
}

func (User) ToSlack

func (u User) ToSlack() string

type Userer

type Userer interface {
	GetUserByEmail(email string) (*User, error)
}

type Workflow

type Workflow struct {
	Name       string `json:"name"`
	HeadBranch string `json:"head_branch"`
	HeadSHA    string `json:"head_sha"`
	Status     string `json:"status"`
	Conclusion string `json:"conclusion"`
	Title      string `json:"display_title"`
	RunNumber  int    `json:"run_number"`
	URL        string `json:"html_url"`
	JobsURL    string `json:"jobs_url"`
	FailedJob  FailedJob
}

func (*Workflow) UpdateFailedJob

func (w *Workflow) UpdateFailedJob() error

type Workflows

type Workflows struct {
	Branches   []string `yaml:"branches"`
	IgnoreBots bool     `yaml:"ignoreBots"`
}

Jump to

Keyboard shortcuts

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