Documentation
¶
Index ¶
- Variables
- type CreateRepositoryFromTemplateOptions
- type CreateRepositoryOptions
- type ForkRepositoryOptions
- type HostingService
- type ListRepositoryOptions
- type OrderDirection
- type ParentRepository
- type Repository
- type RepositoryAffiliation
- type RepositoryFormat
- type RepositoryFormatFunc
- type RepositoryOrder
- type RepositoryOrderField
- type RepositoryPrivacy
- type Tristate
Constants ¶
This section is empty.
Variables ¶
var RepositoryFormatJSON = RepositoryFormatFunc(func(r Repository) (string, error) { j := struct { Ref jsonRef `json:"ref"` URL string `json:"url"` CloneURL string `json:"cloneUrl,omitempty"` UpdatedAt time.Time `json:"updatedAt"` Parent *jsonParent `json:"parent,omitempty"` Description string `json:"description,omitempty"` Homepage string `json:"homepage,omitempty"` Language string `json:"language,omitempty"` Archived bool `json:"archived,omitempty"` Private bool `json:"private,omitempty"` IsTemplate bool `json:"isTemplate,omitempty"` Fork bool `json:"fork,omitempty"` }{ Ref: jsonRef{ Host: r.Ref.Host(), Owner: r.Ref.Owner(), Name: r.Ref.Name(), }, URL: r.URL, CloneURL: r.CloneURL, UpdatedAt: r.UpdatedAt, Description: r.Description, Homepage: r.Homepage, Language: r.Language, Archived: r.Archived, Private: r.Private, IsTemplate: r.IsTemplate, Fork: r.Fork, } if r.Parent != nil { j.Parent = &jsonParent{ Ref: jsonRef{ Host: r.Parent.Ref.Host(), Owner: r.Parent.Ref.Owner(), Name: r.Parent.Ref.Name(), }, CloneURL: r.Parent.CloneURL, } } buf, err := json.Marshal(j) if err != nil { return "", err } return string(buf), nil })
RepositoryFormatJSON formats the repository as a JSON string in oneline
var RepositoryFormatRef = RepositoryFormatFunc(func(r Repository) (string, error) { return r.Ref.String(), nil })
RepositoryFormatRef formats the repository reference as a string
var RepositoryFormatURL = RepositoryFormatFunc(func(r Repository) (string, error) { return r.URL, nil })
RepositoryFormatURL formats the repository URL as a string
Functions ¶
This section is empty.
Types ¶
type CreateRepositoryOptions ¶
type CreateRepositoryOptions struct {
Description string
Homepage string
Organization string
LicenseTemplate string
GitignoreTemplate string
TeamID int64
DisableDownloads bool
IsTemplate bool
Private bool
DisableWiki bool
AutoInit bool
DisableProjects bool
DisableIssues bool
PreventSquashMerge bool
PreventMergeCommit bool
PreventRebaseMerge bool
DeleteBranchOnMerge bool
}
type ForkRepositoryOptions ¶
type ForkRepositoryOptions struct {
DefaultBranchOnly bool
}
type HostingService ¶
type HostingService interface {
// GetURLOf converts a repository reference to its remote URL
GetURLOf(ref repository.Reference) (*url.URL, error)
// ParseURL converts a remote URL to a repository reference
ParseURL(u *url.URL) (*repository.Reference, error)
// GetTokenFor retrieves an authentication token and user for a specific repository reference
GetTokenFor(ctx context.Context, reference repository.Reference) (string, auth.Token, error)
// GetRepository retrieves repository information from a remote source
GetRepository(context.Context, repository.Reference) (*Repository, error)
// ListRepository retrieves a list of repositories from a remote source
ListRepository(context.Context, ListRepositoryOptions) iter.Seq2[*Repository, error]
// DeleteRepository deletes a repository from a remote source
DeleteRepository(context.Context, repository.Reference) error
// CreateRepository creates a new repository on the remote hosting service
CreateRepository(
ctx context.Context,
ref repository.Reference,
opts CreateRepositoryOptions,
) (*Repository, error)
// CreateRepositoryFromTemplate creates a new repository from an existing template repository
CreateRepositoryFromTemplate(
ctx context.Context,
ref repository.Reference,
template repository.Reference,
opts CreateRepositoryFromTemplateOptions,
) (*Repository, error)
// ForkRepository creates a fork of a repository on the remote hosting service
ForkRepository(
ctx context.Context,
ref repository.Reference,
target repository.Reference,
opts ForkRepositoryOptions,
) (*Repository, error)
}
HostingService provides access to remote repositories
type ListRepositoryOptions ¶
type ListRepositoryOptions struct {
// OrderBy specifies the ordering of the repositories
OrderBy RepositoryOrder
// Privacy specifies the privacy level of the repositories
Privacy RepositoryPrivacy
// OwnerAffiliations specifies the affiliations of the user to the repositories
OwnerAffiliations []RepositoryAffiliation
// Limit specifies the maximum number of repositories to return
Limit int
// IsFork filters for repositories that are forks
IsFork Tristate
// IsArchived filters for repositories that are archived
IsArchived Tristate
}
ListRepositoryOptions represents options for listing repositories
type OrderDirection ¶
type OrderDirection int
Possible directions in which to order a list of items when provided an `orderBy` argument.
const ( // Specifies an ascending order for a given `orderBy` argument. OrderDirectionAsc OrderDirection = 1 + iota // Specifies a descending order for a given `orderBy` argument. OrderDirectionDesc )
type ParentRepository ¶
type ParentRepository struct {
// Ref is a reference of the parent repository
Ref repository.Reference
// CloneURL is a clone URL for the parent repository
CloneURL string
}
ParentRepository represents a parent repository of a fork
type Repository ¶
type Repository struct {
// Ref is a reference of the repository
Ref repository.Reference
// URL is a full URL for the repository (e.g.: "https://github.com/kyoh86/gogh")
URL string
// CloneURL is a clone URL for the repository (e.g.: "https://github.com/kyoh86/gogh.git")
CloneURL string
// UpdatedAt is the last updated time of the repository
UpdatedAt time.Time
// Parent is the parent repository if it is a fork
Parent *ParentRepository
// Description is a description of the repository (e.g.: "Gogh is a collection of themes for Gnome Terminal and Pantheon Terminal")
Description string
// Homepage is a homepage of the repository (e.g.: "https://example.com")
Homepage string
// Language is a primary language of the repository (e.g.: "Go")
Language string
// Archived is if the repository is archived
Archived bool
// Private is if the repository is private
Private bool
// IsTemplate is if the repository is a template
IsTemplate bool
// Fork is if the repository is a fork
Fork bool
}
Repository represents a repository on a remote source
type RepositoryAffiliation ¶
type RepositoryAffiliation int
The affiliation of a user to a repository
const ( // Repositories that the user has been added to as a collaborator. RepositoryAffiliationCollaborator RepositoryAffiliation = iota // Repositories that the user has access to through being a member of an // organization. This includes every repository on every team that the user is on. RepositoryAffiliationOrganizationMember // Repositories that are owned by the authenticated user. RepositoryAffiliationOwner )
type RepositoryFormat ¶
type RepositoryFormat interface {
Format(r Repository) (string, error)
}
RepositoryFormat is an interface that defines a method to format a repository
type RepositoryFormatFunc ¶
type RepositoryFormatFunc func(Repository) (string, error)
RepositoryFormatFunc is a function type that implements the RepositoryFormat interface
func (RepositoryFormatFunc) Format ¶
func (f RepositoryFormatFunc) Format(r Repository) (string, error)
Format calls the function itself to format the repository
type RepositoryOrder ¶
type RepositoryOrder struct {
// The ordering direction.
Direction OrderDirection `json:"direction"`
// The field to order repositories by.
Field RepositoryOrderField `json:"field"`
}
Ordering options for repository connections
type RepositoryOrderField ¶
type RepositoryOrderField int
Properties by which repository connections can be ordered.
const ( // Order repositories by creation time RepositoryOrderFieldCreatedAt RepositoryOrderField = iota // Order repositories by name RepositoryOrderFieldName // Order repositories by push time RepositoryOrderFieldPushedAt // Order repositories by number of stargazers RepositoryOrderFieldStargazers // Order repositories by update time RepositoryOrderFieldUpdatedAt )
type RepositoryPrivacy ¶
type RepositoryPrivacy int
The privacy of a repository
const ( // None RepositoryPrivacyNone RepositoryPrivacy = iota // Private RepositoryPrivacyPrivate // Public RepositoryPrivacyPublic )