core

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolHTTPS = "https"
	ProtocolSSH   = "ssh"
)
View Source
const (
	ProviderGithub = "github"
	ProviderGitlab = "gitlab"
)

Variables

View Source
var (
	Fs = afero.NewOsFs()
)

Functions

func ConfigPath

func ConfigPath(rootDir string) string

func EnsureCurrentGit

func EnsureCurrentGit() (string, error)

func EnsureDir

func EnsureDir(paths ...string) error

func GetRootDir

func GetRootDir() (string, error)

func ParseRepositoryGroup

func ParseRepositoryGroup(name string) (string, string, error)

func SortRepositories

func SortRepositories(repos []*Repository)

func SortRepositoryAttachments

func SortRepositoryAttachments(attaches []*RepositoryAttachment)

Types

type Config

type Config struct {
	Workspace string `toml:"workspace"`

	SearchLimit int `toml:"search_limit"`

	Editor string `toml:"editor"`

	Remotes []*Remote `toml:"remotes"`
	// contains filtered or unexported fields
}

func InitConfig

func InitConfig() (*Config, error)

func ReadConfig

func ReadConfig(rootDir string) (*Config, error)

func (*Config) GetRemote

func (c *Config) GetRemote(name string) *Remote

func (*Config) MustGetRemote

func (c *Config) MustGetRemote(name string) (*Remote, error)

func (*Config) Normalize

func (c *Config) Normalize() error

func (*Config) RootDir

func (c *Config) RootDir() string

type Remote

type Remote struct {
	Name string `toml:"name"`
	Host string `toml:"host"`

	Protocol string `toml:"protocol"`

	User  string `toml:"user"`
	Email string `toml:"email"`

	Provider string `toml:"provider"`
	Token    string `toml:"token"`
	API      string `toml:"api"`

	Groups []*RemoteGroup `toml:"groups"`
	// contains filtered or unexported fields
}

func (*Remote) Normalize

func (r *Remote) Normalize(cfg *Config) error

type RemoteGroup

type RemoteGroup struct {
	Prefix string

	Protocol string
	User     string
	Email    string
}

type RemoteRepository

type RemoteRepository struct {
	Name string

	Remote *Remote

	WebURL string

	DefaultBranch string

	Upstream *RemoteRepository

	Archived bool
}

func (*RemoteRepository) Convert

func (r *RemoteRepository) Convert() (*Repository, error)

func (*RemoteRepository) GetUpstreamName added in v0.0.2

func (r *RemoteRepository) GetUpstreamName() string

func (*RemoteRepository) GetUpstreamURL added in v0.0.2

func (r *RemoteRepository) GetUpstreamURL() string

type Repository

type Repository struct {
	Name   string
	Attach string

	View int

	Remote *Remote

	Protocol string
	User     string
	Email    string

	CloneURL string

	Group string
	Base  string
	// contains filtered or unexported fields
}

func NewRepository

func NewRepository(remote *Remote, name string) (*Repository, error)

func ParseRepositoryFullPath

func ParseRepositoryFullPath(cfg *Config, repoFull string) (*Repository, error)

func (*Repository) ColorName

func (repo *Repository) ColorName() string

func (*Repository) Exists

func (repo *Repository) Exists() (bool, error)

func (*Repository) FullName

func (repo *Repository) FullName() string

func (*Repository) Git

func (repo *Repository) Git() *git.Repository

func (*Repository) Normalize

func (repo *Repository) Normalize() error

func (*Repository) Path

func (repo *Repository) Path() string

func (*Repository) PathWithRemote

func (repo *Repository) PathWithRemote() string

type RepositoryAttachment

type RepositoryAttachment struct {
	Path string

	Name   string
	Remote string
}

func (*RepositoryAttachment) FullName

func (a *RepositoryAttachment) FullName() string

type RepositoryMergeOptions

type RepositoryMergeOptions struct {
	Title string

	SourceBranch string
	TargetBranch string

	Upstream *Repository
}

type RepositoryProvider

type RepositoryProvider interface {
	Create(repo *Repository) error
	Remove(repo *Repository) error
	Get(remote *Remote, name string) (*RemoteRepository, error)

	Search(remote *Remote, opts RepositorySearchOptions) ([]*RemoteRepository, error)

	List(remote *Remote, group string) ([]*RemoteRepository, error)

	GetMerge(repo *Repository, opts RepositoryMergeOptions) (string, error)
	CreateMerge(repo *Repository, opts RepositoryMergeOptions) (string, error)

	Fork(repo *Repository, name string) (*RemoteRepository, error)

	GetRelease(repo *Repository, tag string) (*RepositoryRelease, error)
	CreateRelease(repo *Repository, release *RepositoryRelease) (*RepositoryRelease, error)

	UploadReleaseFile(repo *Repository, id interface{}, opts RepositoryUploadReleaseFileOptions) error
}

type RepositoryRelease

type RepositoryRelease struct {
	Title string

	Tag string

	Body string

	Preview bool

	ID     interface{}
	Files  []*RepositoryReleaseFile
	WebURL string
}

type RepositoryReleaseFile

type RepositoryReleaseFile struct {
	Name        string
	DownloadURL string

	Size int64
}

type RepositorySearchOptions

type RepositorySearchOptions struct {
	Group string
	Query string
}

type RepositoryStorage

type RepositoryStorage interface {
	Save(repo *Repository) error

	Remove(repo *Repository) error

	Get(remote *Remote, name string) (*Repository, error)
	GetAttach(path string) (*Repository, error)

	List(remote *Remote) ([]*Repository, error)

	Close() error
}

type RepositoryUploadReleaseFileOptions

type RepositoryUploadReleaseFileOptions struct {
	Name  string
	Label string

	FilePath string

	Reader io.ReadCloser
	Size   int64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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