model

package
v3.2.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package model provides the model of repository and commit. As long as another model that will be use in gitgo command.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Branch

type Branch struct {
	Repository *git.Repository
	Worktree   *git.Worktree
	HEAD       *plumbing.Reference
	Reference  *plumbing.Reference
	KeyList    *List
	// contains filtered or unexported fields
}

func (*Branch) AskCreate

func (b *Branch) AskCreate(requireDesc, requireIter, requireIssue, issueHashtag bool) *Branch

func (*Branch) Checkout

func (b *Branch) Checkout(ref *plumbing.Reference)

func (*Branch) CheckoutD

func (b *Branch) CheckoutD()

func (*Branch) Create

func (b *Branch) Create(name string) *Branch

func (*Branch) CurrentBranch

func (b *Branch) CurrentBranch() plumbing.ReferenceName

func (*Branch) Exist

func (b *Branch) Exist(name string) bool

func (*Branch) List

func (b *Branch) List(all bool, fn func(title string, i int, r *plumbing.Reference))

func (*Branch) NormalizeBranchName

func (b *Branch) NormalizeBranchName(name string) (newname string)

NormalizeBranchName will make name as lower case and remove spacebar

func (*Branch) SetDryrun

func (b *Branch) SetDryrun(isDry bool)

type BranchName

type BranchName struct {
	Iter  string
	Type  string
	Title string
	Desc  string
	Issue string
}

BranchName is the object the create branch name.

func (*BranchName) GetType

func (b *BranchName) GetType() string

GetType will try to format the key to right way. Otherwise, return normal Key

func (*BranchName) Name

func (b *BranchName) Name() string

type Commit

type Commit struct {
	KeyList  *List
	Settings *CommitSettings
	// contains filtered or unexported fields
}

Commit is Commit object of deal with commit things.

func (*Commit) Commit

func (c *Commit) Commit(key string, option CommitOption)

Commit is action for ask the message from user and call CustomCommit.

func (*Commit) CustomCommit

func (c *Commit) CustomCommit(answers CommitMessage, option CommitOption)

CustomCommit will run git commit -m "<message>" with the default format.

func (*Commit) SetSettings

func (c *Commit) SetSettings(scopeSize int, messageSize int)

type CommitMessage

type CommitMessage struct {
	Type       string
	Scope      string
	Title      string
	HasMessage bool
	Message    string
}

CommitMessage is the commit message for save in commit.

func (*CommitMessage) GetMessage

func (c *CommitMessage) GetMessage() string

func (*CommitMessage) GetType

func (c *CommitMessage) GetType() string

GetType will try to format the key to right way. Otherwise, return normal Key

type CommitOption

type CommitOption struct {
	Add     bool
	Empty   bool
	Dry     bool
	Message bool
}

CommitOption is a option of commit

type CommitSettings

type CommitSettings struct {
	ScopeSize   int
	MessageSize int
}

type GitCommand

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

GitCommand is git-cli command with custom stdout and custom stderr

func Git

func Git() *GitCommand

Git will return singleton GitCommand

func (*GitCommand) Exec

func (g *GitCommand) Exec(args ...string) *manager.ErrManager

Exec will run git cli in command line

func (*GitCommand) SetErrWriter

func (g *GitCommand) SetErrWriter(err io.Writer) *GitCommand

SetErrWriter will set err writer

func (*GitCommand) SetOutWriter

func (g *GitCommand) SetOutWriter(out io.Writer) *GitCommand

SetOutWriter will set out writer

func (*GitCommand) SetReader

func (g *GitCommand) SetReader(in io.Reader) *GitCommand

SetReader will set reader

type Header struct {
	Type  string
	Value string
}

Header is struct of Key and Value, using in list.yaml.

func (*Header) Format

func (h *Header) Format() string

Format will return format of string.

func (*Header) String

func (h *Header) String() string

String will return string that show what is it.

type List

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

func (*List) IsContain

func (l *List) IsContain() bool

IsContain check is list have element

func (*List) Load

func (l *List) Load(vp *viper.Viper) *List

func (*List) MakeList

func (l *List) MakeList() []string

MakeList will return header list

func (*List) Merge

func (l *List) Merge(vp *viper.Viper) *List

func (*List) Setup

func (l *List) Setup(key string) *List

type Repo

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

Repo is git repository object for gitgo.

func CustomRepo

func CustomRepo(path string) *Repo

CustomRepo will return repo of custom path

func NewRepo

func NewRepo() *Repo

NewRepo will return new repository with current path. you must call setup for load git repository to memory.

func (*Repo) Add

func (r *Repo) Add(filepath []string) (t *manager.Throwable)

Add get array of filepath, and return ErrManager. anyway, It's will run os.Exit with code 10 if any error occurred.

func (*Repo) AddAll

func (r *Repo) AddAll() *manager.Throwable

AddAll will run git add -A command in cli.

func (*Repo) GetBranch

func (r *Repo) GetBranch() *Branch

func (*Repo) GetCommit

func (r *Repo) GetCommit() *Commit

GetCommit will return Commit object.

func (*Repo) GetGitRepository

func (r *Repo) GetGitRepository() *manager.ResultWrapper

GetGitRepository will return git.Repository of this Repo

func (*Repo) GetRawGitRepository

func (r *Repo) GetRawGitRepository() *git.Repository

GetRawGitRepository will return git.Repository of this Repo, can be nil

func (*Repo) GetRawWorktree

func (r *Repo) GetRawWorktree() *git.Worktree

GetRawWorktree is getter to get worktree, this method can return nil value

func (*Repo) GetWorktree

func (r *Repo) GetWorktree() *manager.ResultWrapper

GetWorktree is getter method, which get git.Worktree from git.Repository.

func (*Repo) Setup

func (r *Repo) Setup()

Setup will load git repository to memory. If any error occurred, exit with code 5.

func (*Repo) Status

func (r *Repo) Status() *manager.ResultWrapper

Status will return *git.Status.

func (*Repo) Throw

func (r *Repo) Throw() *manager.Throwable

type YAML

type YAML struct{}

YAML is object of config yaml

func GeneratorYAML

func GeneratorYAML() *YAML

GeneratorYAML will return YAML Object

func (*YAML) ChgLogConfig

func (y *YAML) ChgLogConfig(style, repoUrl string) string

func (*YAML) ChgLogTpl

func (y *YAML) ChgLogTpl() string

func (*YAML) GDefaultConfig

func (y *YAML) GDefaultConfig() string

GDefaultConfig is global default config.yaml

func (*YAML) GDefaultList

func (y *YAML) GDefaultList() string

GDefaultList is global default list.yaml

func (*YAML) LEmptyList

func (y *YAML) LEmptyList() string

LEmptyList is empty list.yaml

func (*YAML) ReadmeMarkdown

func (y *YAML) ReadmeMarkdown(version string) string

Jump to

Keyboard shortcuts

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