utils

package
v0.0.0-...-e9a104b Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2018 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger = pine.NewWriter("gh")

Logger is the main gh logger instance

Functions

func AutoCompleteRepoName

func AutoCompleteRepoName(repo string) string

AutoCompleteRepoName attempts to autocomplete an incomplete repository name using the GITHUB_USERNAME environment variable

func Confirm

func Confirm(question string, def bool) bool

Confirm shows a prompt on the screen and waits for a user response

func CurrentUserName

func CurrentUserName() (string, bool)

CurrentUserName attempts to get a GitHub username defined in environment variables

func FormatError

func FormatError(err *octokit.ResponseError) string

FormatError attempts to format a given octokit ResponseError

func GetAllCollabs

func GetAllCollabs(url *RepoURL) ([]octokit.User, error)

GetAllCollabs returns a list of all collaborators of a given repository

func GetAllTeamsForOrg

func GetAllTeamsForOrg(org string) ([]octokit.Team, error)

GetAllTeamsForOrg returns a list of all teams for a given organization

func GetAllTeamsForRepo

func GetAllTeamsForRepo(url *RepoURL) ([]octokit.Team, error)

GetAllTeamsForRepo returns a list of teams that have access to a given repository

func GetAllUserRepositories

func GetAllUserRepositories() ([]octokit.Repository, error)

GetAllUserRepositories iterates all API pages and returns a list of repositories that belongs to the authenticated user

func GetAllUsersForOrg

func GetAllUsersForOrg(org string) ([]octokit.User, error)

GetAllUsersForOrg returns a list of users that belongs to an organization

func GetTeamByName

func GetTeamByName(org, team string, logger pine.Writer, exitOnError bool) (*octokit.Team, error)

GetTeamByName returns a Team instance belonging to a given organization under a given name

func GetTeamMembers

func GetTeamMembers(org, team string, logger pine.Writer) ([]octokit.User, *octokit.Team, error)

GetTeamMembers returns a list of members of a given organization team

func HandleClientError

func HandleClientError(resp *octokit.Result, logger pine.Writer)

HandleClientError checks the state of an octokit Result, prints and exits the application if an error ocurred during the request

func NewClient

func NewClient() *octokit.Client

NewClient creates a new Octokit client instance based on the access token obtained from the environment variables

func NormalizeRepoName

func NormalizeRepoName(in string) (string, bool)

NormalizeRepoName tries to normalize a repository name by replacing special characters and stripping a .git suffix from it.

func UserIsOrg

func UserIsOrg(name string) bool

UserIsOrg determines whether a given username is an organization

Types

type Alphabetic

type Alphabetic []string

Alphabetic is reponsible for sorting strings alphabetically ignoring case

func (Alphabetic) Len

func (list Alphabetic) Len() int

func (Alphabetic) Less

func (list Alphabetic) Less(i, j int) bool

func (Alphabetic) Swap

func (list Alphabetic) Swap(i, j int)

type RepoURL

type RepoURL struct {
	Username string
	RepoName string
}

RepoURL represents a username/reponame structure

func RepoURLFromString

func RepoURLFromString(s string) RepoURL

RepoURLFromString creates a new RepoURL struct from a given string

func (*RepoURL) AutoComplete

func (r *RepoURL) AutoComplete()

AutoComplete attempts to autocomplete a RepoURL instance using the GITHUB_USERNAME environment variable

func (*RepoURL) ToURL

func (r *RepoURL) ToURL() string

ToURL transforms the RepoURL into a username/repo string

Jump to

Keyboard shortcuts

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