issuectl

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ToDo       = "To Do"
	InProgress = "In Progress"
	Done       = "Done"
)
View Source
const (
	DefaultStartMessage  = "On it 👀"
	DefaultCloseMessage  = "✅"
	DefaultOpenPRMessage = "Working on changes here: %s"
)
View Source
const (
	GitHubApi = "https://api.github.com/"
)

Variables

View Source
var DefaultConfigFilePath = getDefaultConfigFilePath()
View Source
var DefaultSSHKeyPath = getDefaultSSHKeyPath()
View Source
var Log = NewLogger()

Log is a global logger

Functions

func AddRepoToIssue added in v0.1.8

func AddRepoToIssue(repoName string, issueID IssueID) error

func FinishWorkingOnIssue

func FinishWorkingOnIssue(issueID IssueID) error

FinishWorkingOnIssue finishes work on an issue

func OpenPullRequest

func OpenPullRequest(issueID IssueID, customTitle string) error

OpenPullRequest opens pull request

func StartWorkingOnIssue

func StartWorkingOnIssue(customIssueName string, config IssuectlConfig, issueID IssueID) error

StartWorkingOnIssue starts work on an issue

Types

type BackendConfig

type BackendConfig struct {
	// Name of BackendConfig instance
	Name BackendConfigName `yaml:"name"`

	// BackendType of this BackendConfig
	Type BackendType `yaml:"backendType"`

	GitHub *GitHubConfig `yaml:"github,omitempty"`
	GitLab *GitLabConfig `yaml:"gitlab,omitempty"`
	Jira   *JiraConfig   `yaml:"jira,omitempty"`
}

BackendConfig stores configuration for given BackendType

type BackendConfigName

type BackendConfigName string

BackendConfigName is a name of instance of BackendConfig

type BackendType

type BackendType string

BackendType is a name of issue backend

const (
	BackendGithub BackendType = "github"
	BackendGitLab BackendType = "gitlab"
	BackendJira   BackendType = "jira"
)

BackendGithub is a BackendType for GitHub

type GitHub

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

func NewGitHubClient

func NewGitHubClient(token, baseURL, user string) *GitHub

func (*GitHub) CloseIssue

func (g *GitHub) CloseIssue(owner string, repo RepoConfigName, issueID IssueID) error

func (*GitHub) GetIssue

func (g *GitHub) GetIssue(owner string, repo RepoConfigName, issueID IssueID) (interface{}, error)

func (*GitHub) GetIssueURL added in v0.1.6

func (g *GitHub) GetIssueURL(owner string, repo RepoConfigName, issueID IssueID) (string, error)

func (*GitHub) LinkIssueToRepo

func (g *GitHub) LinkIssueToRepo(owner string, repo RepoConfigName, issueID IssueID, pullRequestID string) error

func (*GitHub) OpenPullRequest

func (g *GitHub) OpenPullRequest(owner string, repo RepoConfigName, title, body, baseBranch, headBranch string) (*int, error)

func (*GitHub) StartIssue added in v0.0.12

func (g *GitHub) StartIssue(owner string, repo RepoConfigName, issueID IssueID) error

type GitHubConfig added in v0.0.12

type GitHubConfig struct {
	Host     string `yaml:"host,omitempty"`
	Token    string `yaml:"token,omitempty"`
	Username string `yaml:"username,omitempty"`
}

type GitLab added in v0.0.5

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

func NewGitLabClient added in v0.0.5

func NewGitLabClient(token, baseURL string, userID int) *GitLab

func (*GitLab) CloseIssue added in v0.0.5

func (g *GitLab) CloseIssue(owner string, repo RepoConfigName, issueID IssueID) error

func (*GitLab) GetIssue added in v0.0.5

func (g *GitLab) GetIssue(owner string, repo RepoConfigName, issueID IssueID) (interface{}, error)

func (*GitLab) GetIssueURL added in v0.1.6

func (g *GitLab) GetIssueURL(owner string, repo RepoConfigName, issueID IssueID) (string, error)

func (*GitLab) LinkIssueToRepo added in v0.0.5

func (g *GitLab) LinkIssueToRepo(owner string, repo RepoConfigName, issueID IssueID, pullRequestID string) error

func (*GitLab) OpenPullRequest added in v0.0.5

func (g *GitLab) OpenPullRequest(owner string, repo RepoConfigName, title, body, baseBranch, headBranch string) (*int, error)

func (*GitLab) StartIssue added in v0.0.12

func (g *GitLab) StartIssue(owner string, repo RepoConfigName, issueID IssueID) error

type GitLabConfig added in v0.0.12

type GitLabConfig struct {
	Host   string `yaml:"host,omitempty"`
	Token  string `yaml:"token,omitempty"`
	UserID int    `yaml:"userID,omitempty"`
}

type GitUser added in v0.0.6

type GitUser struct {
	Name   GitUserName
	Email  string
	SSHKey string
}

GitUser holds config for git user

type GitUserName added in v0.0.6

type GitUserName string

type IssueBackend

type IssueBackend interface {
	LinkIssueToRepo(owner string, repo RepoConfigName, issueID IssueID, pullRequestID string) error
	CloseIssue(owner string, repo RepoConfigName, issueID IssueID) error
	StartIssue(owner string, repo RepoConfigName, issueID IssueID) error
	GetIssue(owner string, repo RepoConfigName, issueID IssueID) (interface{}, error)
	GetIssueURL(owner string, repo RepoConfigName, issueID IssueID) (string, error)
}

type IssueConfig

type IssueConfig struct {
	Name         string            `yaml:"name"`
	ID           IssueID           `yaml:"id"`
	RepoBackend  BackendConfigName `yaml:"repoBackend"`
	IssueBackend BackendConfigName `yaml:"issueBackend"`
	BranchName   string            `yaml:"branchName"`
	Repositories []RepoConfigName  `yaml:"repositories"`
	Dir          string            `yaml:"dir"`
	Profile      ProfileName       `yaml:"profile"`
}

IssueConfig stores configuration for single issue

type IssueID

type IssueID string

IssueID is a unique ID of issue in IssueBackend

type IssuectlConfig

type IssuectlConfig interface {
	GetInMemory() IssuectlConfig
	GetPersistent() IssuectlConfig

	// Profile
	AddProfile(*Profile) error
	DeleteProfile(profileName ProfileName) error
	GetCurrentProfile() ProfileName
	GetProfile(ProfileName) *Profile
	GetProfiles() map[ProfileName]*Profile
	UpdateProfile(*Profile) error
	UseProfile(profile ProfileName) error

	// Issues
	AddIssue(issueConfig *IssueConfig) error
	DeleteIssue(issueID IssueID) error
	GetIssue(IssueID) (*IssueConfig, bool)
	GetIssues() map[IssueID]*IssueConfig

	// Repositories
	AddRepository(repoConfig *RepoConfig) error
	GetRepository(name RepoConfigName) *RepoConfig
	GetRepositories() map[RepoConfigName]*RepoConfig

	// Backends
	AddBackend(backend *BackendConfig) error
	DeleteBackend(backendName BackendConfigName) error
	GetBackend(backendName BackendConfigName) *BackendConfig
	GetBackends() map[BackendConfigName]*BackendConfig

	// GitUsers
	AddGitUser(user *GitUser) error
	DeleteGitUser(userName GitUserName) error
	GetGitUser(userName GitUserName) (*GitUser, bool)
	GetGitUsers() map[GitUserName]*GitUser

	Save() error // TODO: this shouldn't be exposed
}

func GetConfig added in v0.0.11

func GetEmptyConfig added in v0.0.11

func GetEmptyConfig() IssuectlConfig

func LoadConfig

func LoadConfig() IssuectlConfig

type Jira added in v0.0.12

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

func NewJiraClient added in v0.0.12

func NewJiraClient(email, apiToken, baseURL string) *Jira

func (*Jira) CloseIssue added in v0.0.12

func (j *Jira) CloseIssue(owner string, repo RepoConfigName, issueID IssueID) error

func (*Jira) GetIssue added in v0.0.12

func (j *Jira) GetIssue(owner string, repo RepoConfigName, issueID IssueID) (interface{}, error)

func (*Jira) GetIssueURL added in v0.1.6

func (j *Jira) GetIssueURL(owner string, repo RepoConfigName, issueID IssueID) (string, error)

func (*Jira) LinkIssueToRepo added in v0.0.12

func (j *Jira) LinkIssueToRepo(owner string, repo RepoConfigName, issueID IssueID, pullRequestID string) error

func (*Jira) StartIssue added in v0.0.12

func (j *Jira) StartIssue(owner string, repo RepoConfigName, issueID IssueID) error

type JiraConfig added in v0.0.12

type JiraConfig struct {
	Host     string `yaml:"host,omitempty"`
	Token    string `yaml:"token,omitempty"`
	Username string `yaml:"username,omitempty"`
}

type Logger

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

Logger struct holds the verbosity level

func NewLogger

func NewLogger() *Logger

NewLogger parses command line argument for verbosity level and returns a new Logger

func (*Logger) Infof

func (l *Logger) Infof(format string, v ...interface{})

Infof formats the log message and calls output function with default level 1

func (*Logger) Infofp added in v0.1.4

func (l *Logger) Infofp(emoji string, format string, v ...interface{})

Infofp formats the log message, adds prefix to it and calls output function with default level 1

func (*Logger) V

func (l *Logger) V(level int) *verbosityLogger

V returns a verbosityLogger with the specified verbosity level

type Profile

type Profile struct {
	Name         ProfileName       `yaml:"name"`
	WorkDir      string            `yaml:"workDir"`
	IssueBackend BackendConfigName `yaml:"issueBackend"`
	RepoBackend  BackendConfigName `yaml:"repoBackend"`
	GitUserName  GitUserName       `yaml:"gituser"`
	Repositories []RepoConfigName  `yaml:"repositories"`

	// DefaultRepository is now used for Github IssueBackend
	DefaultRepository RepoConfigName `yaml:"defaultRepository"`
}

Profile is a config profile

func (*Profile) AddRepository added in v0.0.4

func (p *Profile) AddRepository(repo RepoConfigName) error

type ProfileName

type ProfileName string

ProfileName is a name of issuectl config profile

type RepoConfig

type RepoConfig struct {
	// Name of this repo
	Name RepoConfigName `yaml:"name"`

	// Repo owner
	Owner string `yaml:"owner"`

	// URL to this repo
	RepoURL RepoURL `yaml:"url"`
}

RepoConfig stores configuration for given git repo

type RepoConfigName

type RepoConfigName string

RepoConfigName is a name of git repo

type RepoURL

type RepoURL string

RepoURL is a string with URL to git repo for cloning

type RepositoryBackend added in v0.0.5

type RepositoryBackend interface {
	OpenPullRequest(owner string, repo RepoConfigName, title, body, baseBranch, headBranch string) (*int, error)
}

type TextConfig added in v0.1.5

type TextConfig struct {
	StartMessage  string `yaml:"startMessage"`
	CloseMessage  string `yaml:"closeMessage"`
	OpenPRMessage string `yaml:"openPRMessage"`
}

Jump to

Keyboard shortcuts

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