remote

package
v0.0.0-...-855de17 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const PageMax = 2
View Source
const PerPage = 50 // 100 is max

Variables

View Source
var Branches = map[LeafHeader][]LeafHeader{
	OrgRepos: {Members},
	Members:  {Starred, Authored, Following, Followers},

	Stargazers: {Starred, Authored, Following, Followers},

	Starred:   {Stargazers},
	Authored:  {Stargazers},
	Following: {Starred, Authored},
	Followers: {Starred, Authored},
}

these are completely fucked. i don't understand what i'm trying to do here.

Functions

This section is empty.

Types

type ErrFilteredT

type ErrFilteredT struct {
	Reason   string
	Value    interface{}
	Resource string
}

func (*ErrFilteredT) String

func (e *ErrFilteredT) String() string

type ForkConfig

type ForkConfig struct {
	Org string // organization to fork repo to; if empty will fork to auth'd user
}

type ForkedOutcome

type ForkedOutcome struct {
	GitUrl   string
	HTMLUrl  string
	CloneUrl string
}

func (*ForkedOutcome) String

func (fo *ForkedOutcome) String() string

type FormattedOutcome

type FormattedOutcome struct {
	CommitHash string
	GitStatus  string
}

func (*FormattedOutcome) String

func (fo *FormattedOutcome) String() string

type GoogleGithubRepoProvider

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

GoogleGithubRepoProvider implements the Provider interface using the google/go-github API package.

func NewGoogleGithubProvider

func NewGoogleGithubProvider(username, token string) *GoogleGithubRepoProvider

func (*GoogleGithubRepoProvider) Cancel

func (rp *GoogleGithubRepoProvider) Cancel()

func (*GoogleGithubRepoProvider) CreatePullRequest

func (rp *GoogleGithubRepoProvider) CreatePullRequest(pr *PullRequestT, branchNameBase string) (err error)

func (*GoogleGithubRepoProvider) FetchLeaf

func (rp *GoogleGithubRepoProvider) FetchLeaf(leaf Leaf, spec *RepoListSpec) (fetched []interface{}, err error)

func (*GoogleGithubRepoProvider) FetchRepo

func (rp *GoogleGithubRepoProvider) FetchRepo(r *RepoT) (rawRepo interface{}, err error)

func (*GoogleGithubRepoProvider) FilterOwner

func (rp *GoogleGithubRepoProvider) FilterOwner(rawOwner interface{}, spec *OwnerListSpec) (err *ErrFilteredT)

func (*GoogleGithubRepoProvider) FilterRepo

func (rp *GoogleGithubRepoProvider) FilterRepo(rawRepo interface{}, spec *RepoListSpec) (err *ErrFilteredT)

func (*GoogleGithubRepoProvider) ForkRepo

func (rp *GoogleGithubRepoProvider) ForkRepo(config *ForkConfig, oR *RepoT) (origAndForked [2]*RepoT, err error)

func (*GoogleGithubRepoProvider) GetClient

func (rp *GoogleGithubRepoProvider) GetClient() *http.Client

func (*GoogleGithubRepoProvider) ToOwner

func (rp *GoogleGithubRepoProvider) ToOwner(rawOwner interface{}) (owner *Owner, ok bool)

func (*GoogleGithubRepoProvider) ToRepo

func (rp *GoogleGithubRepoProvider) ToRepo(rawRepo interface{}) (repo *RepoT, ok bool)

type Leaf

type Leaf struct {
	Header LeafHeader
	ID     string // eg. rotblauer or rotblauger/go-fmtatt
}

func (Leaf) GetOwner

func (l Leaf) GetOwner() *Owner

func (Leaf) IsRepo

func (l Leaf) IsRepo() bool

func (Leaf) String

func (l Leaf) String() string

type LeafHeader

type LeafHeader string
const (
	Followers LeafHeader = "user_followers"
	Following            = "user_following"
)

Owner-user leafs

const (
	Starred  LeafHeader = "user_starred"
	Authored            = "user_authored"
)

Owner-repo leafs

const (
	Members LeafHeader = "org_members"
)

Org-user leafs

const (
	OrgRepos LeafHeader = "org_owns"
)

Org-repo leafs

const (
	Stargazers LeafHeader = "repo_stargazers"
)

Repo-user leafs

func (LeafHeader) BranchesFromOrg

func (l LeafHeader) BranchesFromOrg() bool

func (LeafHeader) BranchesFromRepo

func (l LeafHeader) BranchesFromRepo() bool

func (LeafHeader) BranchesFromUser

func (l LeafHeader) BranchesFromUser() bool

func (LeafHeader) IsListOfRepos

func (l LeafHeader) IsListOfRepos() bool

type ListSpec

type ListSpec struct {
	*RepoListSpec
	*OwnerListSpec
}

type MatchNSpec

type MatchNSpec struct {
	Min, Max int64
}

type MatchTextSpec

type MatchTextSpec struct {
	WhiteList []string
	BlackList []string
}

type MatchTimeSpec

type MatchTimeSpec struct {
	Earliest, Latest time.Time
}

type OrganizationListSpec

type OrganizationListSpec struct {
	OwnerListSpec
}

type Outcome

type Outcome struct {
	Status OutcomeStatus

	Error            string // gotcha. Error, not Err // nope. fuck it.
	FilteredE        *ErrFilteredT
	Timestamp        time.Time
	FormattedOutcome *FormattedOutcome
	ForkedOutcome    *ForkedOutcome
	PROutcome        *PullRequestT
}

func (*Outcome) SetErr

func (o *Outcome) SetErr(e error)

func (Outcome) String

func (s Outcome) String() string

type OutcomeStatus

type OutcomeStatus int
const (
	DBErr   OutcomeStatus = iota // unknown to db
	Invalid                      // filtered out by metadata
	Clean                        // fmting did nothing (repo worktree was clean)
	Valid                        // cleared by metadata for formatting
	Dirty                        // fmting did something
	Committed
	Forked        // did fork
	PullRequested // did pr
)

type Owner

type Owner struct {
	Name   string
	KindOf string // "Owner" "Organization"
}

func (*Owner) String

func (o *Owner) String() string

type OwnerListSpec

type OwnerListSpec struct {
	Owner
	FollowingN     *MatchNSpec
	FollowersN     *MatchNSpec
	PublicReposN   *MatchNSpec
	PublicGistsN   *MatchNSpec
	CollaboratorsN *MatchNSpec
	Hireable       string // "true", "false", ""
}

OwnerListSpec can be user or org

type OwnerPool

type OwnerPool []*Owner

func (*OwnerPool) AsStrings

func (op *OwnerPool) AsStrings() (candidates []string)

func (*OwnerPool) Has

func (op *OwnerPool) Has(o *Owner) bool

func (*OwnerPool) Len

func (op *OwnerPool) Len() int

func (*OwnerPool) Pop

func (op *OwnerPool) Pop() *Owner

func (*OwnerPool) Push

func (op *OwnerPool) Push(o *Owner)

OwnerPool deals with the randomness from Walker

func (*OwnerPool) Splice

func (op *OwnerPool) Splice(o *Owner) (ow *Owner)

type Provider

type Provider interface {
	GetClient() *http.Client
	FetchRepo(repo *RepoT) (rawRepo interface{}, err error)
	FetchLeaf(leaf Leaf, spec *RepoListSpec) (fetched []interface{}, err error)
	FilterRepo(rawRepo interface{}, spec *RepoListSpec) (err *ErrFilteredT)
	FilterOwner(rawOwner interface{}, spec *OwnerListSpec) (err *ErrFilteredT)
	ToRepo(rawRepo interface{}) (repo *RepoT, ok bool)
	ToOwner(rawUser interface{}) (owner *Owner, ok bool)
	ForkRepo(config *ForkConfig, rs *RepoT) (repos [2]*RepoT, err error)
	CreatePullRequest(pr *PullRequestT, branchNameBase string) (err error)
	Cancel()
}

type PullRequestConfig

type PullRequestConfig struct {
	Title    string
	Head     string `json:"-",toml:"-",yaml:"-"` // (branch name to Set Set changes to; create PR rom) Default to an automatic probably-unique one, like types-20180606
	Base     string `json:"-",toml:"-",yaml:"-"` // Default to 'master'
	Body     string
	BodyFile string
	OrgFork  string // Organization name
}

type PullRequestT

type PullRequestT struct {
	*RepoT
	*PullRequestConfig
	// on success, we store these
	Number int
	ID     int64
}

func (*PullRequestT) String

func (pr *PullRequestT) String() string

type QueryBranchConfig

type QueryBranchConfig struct {
	MaxDistance int // tricky
	Branching   map[LeafHeader]float64
}

type RemoteError

type RemoteError struct {
	Err        error
	Status     string
	StatusCode int
	Msg        string
}

func (RemoteError) String

func (r RemoteError) String() string

type RepoListSpec

type RepoListSpec struct {
	*SearchOptions
	OwnerType       string // "user" OR "org" OR "" for either
	Visibility      string // "private", "public", "all"
	Affiliation     string // owner,collaborator,organization_member
	Owner           *MatchTextSpec
	Name            *MatchTextSpec
	Language        *MatchTextSpec
	Conduct         *MatchTextSpec // eg. "NO ROBOTS" :( or "ROBOTS WECOME"!
	Description     *MatchTextSpec
	IsFork          bool
	IsPrivate       bool
	Archived        bool
	StargazersCount *MatchNSpec
	ForksCount      *MatchNSpec
	WatchersCount   *MatchNSpec
	NetworkCount    *MatchNSpec
	Size            *MatchNSpec
	CreatedAt       *MatchTimeSpec
	UpdatedAt       *MatchTimeSpec
	FmtExpiration   time.Duration `json:"-",toml:"-",yaml:"-"` // parse the below to this on init
	FmtExpiry       int           // in DAYS.
}

type RepoPool

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

func NewRepoPool

func NewRepoPool() *RepoPool

func (*RepoPool) GetOutcome

func (rp *RepoPool) GetOutcome(r *RepoT) *Outcome

func (*RepoPool) GetWhere

func (rp *RepoPool) GetWhere(filter func(r *RepoT, o *Outcome) bool) (repos []*RepoT)

func (*RepoPool) Len

func (rp *RepoPool) Len() int

func (*RepoPool) Random1

func (rp *RepoPool) Random1() *RepoT

func (*RepoPool) Remove

func (rp *RepoPool) Remove(r *RepoT)

func (*RepoPool) Repos

func (rp *RepoPool) Repos() (repos []*RepoT)

func (*RepoPool) Set

func (rp *RepoPool) Set(r *RepoT, o *Outcome)

RepoPool is FIFO, for now

type RepoT

type RepoT struct {
	Owner    *Owner
	Name     string
	Target   string // filepath of clone
	CloneUrl string
	GitUrl   string
	HTMLUrl  string
}

func RepoizeRef

func RepoizeRef(fullName string) *RepoT

func (*RepoT) GuessURLs

func (r *RepoT) GuessURLs(provider string)

func (*RepoT) Ref

func (r *RepoT) Ref() string

func (*RepoT) String

func (r *RepoT) String() string

type Resource

type Resource struct {
	Owner *Owner
	Repo  *RepoT
}

type SearchOptions

type SearchOptions struct {
	Sort  string
	Order string
}

type UserListSpec

type UserListSpec struct {
	OwnerListSpec
}

Jump to

Keyboard shortcuts

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