gitw

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 21 Imported by: 3

README

GitW

GitHub go.mod Go version GitHub tag (latest SemVer) GoDoc Go Report Card Unit-Tests Coverage Status

gitw - Git command wrapper, git changelog, repo information and some git tools.

Github https://github.com/gookit/gitw

  • Wrap the local git commands
  • Quick run a git command
  • Quick query repository information
  • Generate changelog by git log
    • Allow custom generate config, such as filter, style and more

Install

required: go 1.14+, git 2.x

go get github.com/gookit/gitw

Usage

package main

import (
	"fmt"

	"github.com/gookit/gitw"
)

func main() {
	// logTxt, err := gitw.ShowLogs("v1.0.2", "v1.0.3")
	logTxt := gitw.MustString(gitw.ShowLogs("v1.0.2", "v1.0.3"))
	fmt.Println(logTxt)

	// Local Branches
	brList := gitw.MustStrings(gitw.Branches())
	fmt.Println(brList)

	// custom create command

	logCmd := gitw.New("log", "-2")
	// git.Run()
	// txt, err := logCmd.Output()
	txt := logCmd.SafeOutput()

	fmt.Println(txt)
}

Repository

You can quickly get a git repository information at local.

repo := gitw.NewRepo("/path/to/my-repo")

Remote Information:

rt := repo.DefaultRemoteInfo()

dump.Println(rt)

Output:

one-remote-info

Repo Information:

dump.Println(repo.Info())

Output:

simple-repo-info

Changelog

You can quickly generate changelog by gitw/chlog package.

Install
go install github.com/gookit/gitw/cmd/chlog@latest
Usage

Please run chlog -h to see help:

chlog-help

Example Run:

chlog last head
chlog -config .github/changelog.md last head

Outputs:

## Change Log

### Update

- update: update some logic for git command run [96147fb](https://github.com/gookit/gitw/commit/96147fba43caf462a50bc97d7ed078dd0059e797)
- update: move RepoUrl config to MarkdownFormatter [8c861bf](https://github.com/gookit/gitw/commit/8c861bf05ae3576aba401692124df63372ae9ed7)

### Fixed

- fix: gen changelog error [1636761](https://github.com/gookit/gitw/commit/16367617bc364ce1022097e89313c7b09983981a)

### Other

- style: update some code logic [4a9f146](https://github.com/gookit/gitw/commit/4a9f14656b26a08b0cdd9c4f9cec9ae3bf5938b1)
- build(deps): bump github.com/gookit/color from 1.4.2 to 1.5.0 [037fa47](https://github.com/gookit/gitw/commit/037fa477954b630fe34ff7ceab51e6132db645cb)
- style: update examples and readme [8277389](https://github.com/gookit/gitw/commit/8277389817917e6b0cb97f3e5629f2c5034075e4)

Use on action

Can use gitw/chlog on GitHub actions, like:

Full script please see .github/workflows/release.yml

# ...

    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Setup Go Faster
        uses: WillAbides/setup-go-faster@v1.7.0
        timeout-minutes: 3
        with:
          go-version: 1.17 # or use ${{ matrix.go_version }} 

      - name: Generate changelog
        run: |
          go install github.com/gookit/gitw/cmd/chlog@latest
          chlog -config .github/changelog.yml -output changelog.md prev last 

Use in code
package main

import (
	"fmt"

	"github.com/gookit/gitw/chlog"
	"github.com/gookit/goutil"
)

func main() {
	cl := chlog.New()
	cl.Formatter = &chlog.MarkdownFormatter{
		RepoURL: "https://github.com/gookit/gitw",
	}
	cl.WithConfig(func(c *chlog.Config) {
		// some settings ...
		c.Title = "## Change Log"
	})

	// fetch git log
	cl.FetchGitLog("v0.1.0", "HEAD", "--no-merges")

	// do generate
	goutil.PanicIfErr(cl.Generate())

	// dump
	fmt.Println(cl.Changelog())
}

Commands

Commonly functions

Git command functions of std:

func Alias(name string) string
func CommentChar(text string) (string, error)
func Config(name string) string
func ConfigAll(name string) ([]string, error)
func Dir() (string, error)
func Editor() string
func GlobalConfig(name string) (string, error)
func HasFile(segments ...string) bool
func Head() (string, error)
func Branches() ([]string, error)
func Log(sha1, sha2 string) (string, error)
func Tag(args ...string) (string, error)
func Quiet(args ...string) bool
func Ref(ref string) (string, error)
func RefList(a, b string) ([]string, error)
func Remotes() ([]string, error)
func Run(args ...string) error
func SetGlobalConfig(name, value string) error
func Show(sha string) (string, error)
func Spawn(args ...string) error
func SymbolicFullName(name string) (string, error)
func SymbolicRef(ref string) (string, error)
func Var(name string) string
func Version() (string, error)
func WorkdirName() (string, error)

Util functions:

func SetDebug()
func ParseURL(rawURL string) (u *url.URL, err error)
func IsGitCommand(command string) bool
func IsGitDir(dir string) bool
func MustString(s string, err error) string
func MustStrings(ss []string, err error) []string
func EditText(data string) string

Refer

Documentation

Overview

Package gitw git command wrapper, git changelog, repo information and some git tools.

Index

Constants

View Source
const (
	ProtoSSH  = "ssh"
	ProtoHTTP = "http"

	SchemeGIT   = "git"
	SchemeHTTP  = "http"
	SchemeHTTPS = "https"
)

some consts for remote info

View Source
const (
	RemoteTypePush  = "push"
	RemoteTypeFetch = "fetch"
)

remote type names

View Source
const GitDir = ".git"

GitDir name

Variables

View Source
var (
	// DefaultBin name
	DefaultBin = "git"

	// DefaultBranchName value
	DefaultBranchName = "master"
	// DefaultRemoteName value
	DefaultRemoteName = "origin"
)
View Source
var ErrRemoteInfoNil = errorx.Raw("the remote info data cannot be nil")

ErrRemoteInfoNil error

View Source
var GlobalFlags []string

GlobalFlags for run git command

Functions

func Alias

func Alias(name string) string

Alias find

func AllVars

func AllVars() string

AllVars get all git vars

func Branches

func Branches() ([]string, error)

Branches list

func CommentChar

func CommentChar(text string) (string, error)

CommentChar find

func Config

func Config(name string) string

Config get git config by name

func ConfigAll

func ConfigAll(name string) ([]string, error)

ConfigAll get

func DataDir

func DataDir() (string, error)

DataDir get .git dir name. eg: ".git"

func EditText

func EditText(data string) string

EditText starts an editor to edit data, and returns the edited data.

func Editor

func Editor() string

Editor returns program name of the editor. from https://github.com/alibaba/git-repo-go/blob/master/editor/editor.go

func FirstLine

func FirstLine(output string) string

FirstLine from command output

func GlobalConfig

func GlobalConfig(name string) (string, error)

GlobalConfig get git global config by name

func HasDotGitDir

func HasDotGitDir(path string) bool

HasDotGitDir in the path

func HasFile

func HasFile(segments ...string) bool

HasFile check

func Head() (string, error)

Head read current branch name. return like: "refs/heads/main"

func IsDebug

func IsDebug() bool

IsDebug mode

func IsGitCmd

func IsGitCmd(command string) bool

IsGitCmd check

func IsGitCommand

func IsGitCommand(command string) bool

IsGitCommand check

func IsGitDir

func IsGitDir(dir string) bool

IsGitDir check

func MustString

func MustString(s string, err error) string

MustString must return string, will panic on error

func MustStrings

func MustStrings(ss []string, err error) []string

MustStrings must return strings, will panic on error

func OutputLines

func OutputLines(output string) []string

OutputLines split output to lines

func ParseRemoteURL

func ParseRemoteURL(URL string, r *RemoteInfo) (err error)

ParseRemoteURL info to the RemoteInfo object.

func PrintCmdline

func PrintCmdline(gw *GitWrap)

PrintCmdline on exec

func Quiet

func Quiet(args ...string) bool

Quiet run

func Ref

func Ref(ref string) (string, error)

Ref get

func RefList

func RefList(a, b string) ([]string, error)

RefList for two sha

func Remotes

func Remotes() ([]string, error)

Remotes list

func RestStd

func RestStd()

RestStd instance

func Run

func Run(args ...string) error

Run command with args

func SetDebug

func SetDebug(open bool)

SetDebug mode

func SetGlobalConfig

func SetGlobalConfig(name, value string) error

SetGlobalConfig by name

func SetWorkdir

func SetWorkdir(dir string)

SetWorkdir for the std

func ShowDiff

func ShowDiff(sha string) (string, error)

ShowDiff git log diff by a commit sha

func ShowLogs

func ShowLogs(sha1, sha2 string) (string, error)

ShowLogs show git log between sha1 to sha2

Usage:

gitw.ShowLogs("v1.0.2", "v1.0.3")
gitw.ShowLogs("commit id 1", "commit id 2")

func Spawn

func Spawn(args ...string) error

Spawn run command with args

func SymbolicFullName

func SymbolicFullName(name string) (string, error)

SymbolicFullName reads a branch name from a ref such as "@{upstream}"

func SymbolicRef

func SymbolicRef(ref string) (string, error)

SymbolicRef reads a branch name from a ref such as "HEAD"

func Tags

func Tags(args ...string) ([]string, error)

Tags list

something:

`git tag -l` == `git tag --format '%(refname:strip=2)'`

more e.g:

 // refname - sorts in a lexicographic order
 // version:refname or v:refname - this sorts based on version
	git tag --sort=-version:refname
	git tag -l --sort version:refname
	git tag --format '%(refname:strip=2)' --sort=-taggerdate
	git tag --format '%(refname:strip=2) %(objectname)' --sort=-taggerdate
	git log --tags --simplify-by-decoration --pretty="format:%d - %cr"

func Var

func Var(name string) string

Var get by git var.

Example

all: git var -l
one: git var GIT_EDITOR

func Version

func Version() (string, error)

Version info git.

func Workdir

func Workdir() (string, error)

Workdir git workdir name. alias of WorkdirName()

func WorkdirName

func WorkdirName() (string, error)

WorkdirName get git workdir name

Types

type GitWrap

type GitWrap struct {
	// Workdir for run git
	Workdir string
	// Bin git bin name. default is "git"
	Bin string
	// Args for run git. contains git command name.
	Args []string
	// Stdin more settings
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
	// BeforeExec command hook.
	//
	// Usage: gw.BeforeExec = gitw.PrintCmdline
	BeforeExec func(gw *GitWrap)
}

GitWrap is a project-wide struct that represents a command to be run in the console.

func Branch

func Branch(args ...string) *GitWrap

Branch command of git

func Cmd

func Cmd(cmd string, args ...string) *GitWrap

Cmd create instance with git cmd and args

func Log

func Log(args ...string) *GitWrap

Log command of git

Usage: Log("-2").OutputLines()

func New

func New(args ...string) *GitWrap

New create instance with args

func NewWithArgs

func NewWithArgs(cmd string, args ...string) *GitWrap

NewWithArgs create instance with git cmd and args

func NewWithWorkdir

func NewWithWorkdir(workdir string, args ...string) *GitWrap

NewWithWorkdir create instance with workdir and args

func Remote

func Remote(args ...string) *GitWrap

Remote command of git

func RevList

func RevList(args ...string) *GitWrap

RevList command of git

func Show

func Show(args ...string) *GitWrap

Show command of git

func Std

func Std() *GitWrap

Std instance get

func Tag

func Tag(args ...string) *GitWrap

Tag command of git

Usage: Tag("-l").OutputLines()

func (*GitWrap) Add

func (gw *GitWrap) Add(args ...string) *GitWrap

Add command for git

func (*GitWrap) AddArg

func (gw *GitWrap) AddArg(args ...string) *GitWrap

AddArg add args and returns the current object

func (*GitWrap) AddArgs

func (gw *GitWrap) AddArgs(args []string) *GitWrap

AddArgs for the git. alias of WithArgs()

func (*GitWrap) Annotate

func (gw *GitWrap) Annotate(args ...string) *GitWrap

Annotate command for git

func (*GitWrap) Apply

func (gw *GitWrap) Apply(args ...string) *GitWrap

Apply command for git

func (*GitWrap) ArgIf

func (gw *GitWrap) ArgIf(arg string, exprOk bool) *GitWrap

ArgIf add arg and returns the current object

func (*GitWrap) Argf

func (gw *GitWrap) Argf(format string, args ...interface{}) *GitWrap

Argf add arg and returns the current object.

func (*GitWrap) Bisect

func (gw *GitWrap) Bisect(args ...string) *GitWrap

Bisect command for git

func (*GitWrap) Blame

func (gw *GitWrap) Blame(args ...string) *GitWrap

Blame command for git

func (*GitWrap) Branch

func (gw *GitWrap) Branch(args ...string) *GitWrap

Branch command for git

func (*GitWrap) Checkout

func (gw *GitWrap) Checkout(args ...string) *GitWrap

Checkout command for git

func (*GitWrap) CherryPick

func (gw *GitWrap) CherryPick(args ...string) *GitWrap

CherryPick command for git

func (*GitWrap) Clean

func (gw *GitWrap) Clean(args ...string) *GitWrap

Clean command for git

func (*GitWrap) Clone

func (gw *GitWrap) Clone(args ...string) *GitWrap

Clone command for git

func (*GitWrap) Cmd

func (gw *GitWrap) Cmd(cmd string, args ...string) *GitWrap

Cmd new git wrap from current instance, can with args

func (*GitWrap) Cmdline

func (gw *GitWrap) Cmdline() string

Cmdline to command line

func (*GitWrap) CombinedOutput

func (gw *GitWrap) CombinedOutput() (string, error)

CombinedOutput run and return output, will combine stderr and stdout output

func (*GitWrap) Commit

func (gw *GitWrap) Commit(args ...string) *GitWrap

Commit command for git

func (*GitWrap) Config

func (gw *GitWrap) Config(args ...string) *GitWrap

Config command for git

func (*GitWrap) Describe

func (gw *GitWrap) Describe(args ...string) *GitWrap

Describe command for git

func (*GitWrap) Diff

func (gw *GitWrap) Diff(args ...string) *GitWrap

Diff command for git

func (*GitWrap) Exec

func (gw *GitWrap) Exec() error

Exec runs command with exec(3) Note that Windows doesn't support exec(3): http://golang.org/src/pkg/syscall/exec_windows.go#L339

func (*GitWrap) Fetch

func (gw *GitWrap) Fetch(args ...string) *GitWrap

Fetch command for git

func (*GitWrap) GitDir

func (gw *GitWrap) GitDir() string

GitDir return .git data dir

func (*GitWrap) Grep

func (gw *GitWrap) Grep(args ...string) *GitWrap

Grep command for git

func (*GitWrap) Init

func (gw *GitWrap) Init(args ...string) *GitWrap

Init command for git

func (*GitWrap) IsGitRepo

func (gw *GitWrap) IsGitRepo() bool

IsGitRepo return the work dir is a git repo.

func (*GitWrap) Log

func (gw *GitWrap) Log(args ...string) *GitWrap

Log command for git

func (*GitWrap) Merge

func (gw *GitWrap) Merge(args ...string) *GitWrap

Merge command for git

func (*GitWrap) MustRun

func (gw *GitWrap) MustRun()

MustRun a command. will panic on error

func (*GitWrap) Mv

func (gw *GitWrap) Mv(args ...string) *GitWrap

Mv command for git

func (*GitWrap) New

func (gw *GitWrap) New(args ...string) *GitWrap

New git wrap from current instance, can with args

func (*GitWrap) NewExecCmd

func (gw *GitWrap) NewExecCmd() *exec.Cmd

NewExecCmd create exec.Cmd from current cmd

func (*GitWrap) OnBeforeExec

func (gw *GitWrap) OnBeforeExec(fn func(gw *GitWrap)) *GitWrap

OnBeforeExec add hook

func (*GitWrap) Output

func (gw *GitWrap) Output() (string, error)

Output run and return output

func (*GitWrap) OutputLines

func (gw *GitWrap) OutputLines() ([]string, error)

OutputLines run and return output as lines

func (*GitWrap) Pull

func (gw *GitWrap) Pull(args ...string) *GitWrap

Pull command for git

func (*GitWrap) Push

func (gw *GitWrap) Push(args ...string) *GitWrap

Push command for git

func (*GitWrap) Rebase

func (gw *GitWrap) Rebase(args ...string) *GitWrap

Rebase command for git

func (*GitWrap) Reflog

func (gw *GitWrap) Reflog(args ...string) *GitWrap

Reflog command for git

func (*GitWrap) Remote

func (gw *GitWrap) Remote(args ...string) *GitWrap

Remote command for git

func (*GitWrap) Reset

func (gw *GitWrap) Reset(args ...string) *GitWrap

Reset command for git

func (*GitWrap) ResetArgs

func (gw *GitWrap) ResetArgs()

ResetArgs for git

func (*GitWrap) Restore

func (gw *GitWrap) Restore(args ...string) *GitWrap

Restore command for git

func (*GitWrap) RevList

func (gw *GitWrap) RevList(args ...string) *GitWrap

RevList command for git

func (*GitWrap) RevParse

func (gw *GitWrap) RevParse(args ...string) *GitWrap

RevParse command for git

rev-parse usage:

git rev-parse --show-toplevel // get git workdir, repo dir.
git rev-parse -q --git-dir // get git data dir name. eg: .git

func (*GitWrap) Revert

func (gw *GitWrap) Revert(args ...string) *GitWrap

Revert command for git

func (*GitWrap) Rm

func (gw *GitWrap) Rm(args ...string) *GitWrap

Rm command for git

func (*GitWrap) Run

func (gw *GitWrap) Run() error

Run runs command with `Exec` on platforms except Windows which only supports `Spawn`

func (*GitWrap) SafeLines

func (gw *GitWrap) SafeLines() []string

SafeLines run and return output as lines

func (*GitWrap) SafeOutput

func (gw *GitWrap) SafeOutput() string

SafeOutput run and return output

func (*GitWrap) ShortLog

func (gw *GitWrap) ShortLog(args ...string) *GitWrap

ShortLog command for git

func (*GitWrap) Show

func (gw *GitWrap) Show(args ...string) *GitWrap

Show command for git

func (*GitWrap) Spawn

func (gw *GitWrap) Spawn() error

Spawn runs command with spawn(3)

func (*GitWrap) Stash

func (gw *GitWrap) Stash(args ...string) *GitWrap

Stash command for git

func (*GitWrap) Status

func (gw *GitWrap) Status(args ...string) *GitWrap

Status command for git

func (*GitWrap) String

func (gw *GitWrap) String() string

String to command line

func (*GitWrap) Sub

func (gw *GitWrap) Sub(cmd string, args ...string) *GitWrap

Sub new sub git cmd from current instance, can with args

func (*GitWrap) Success

func (gw *GitWrap) Success() bool

Success run and return whether success

func (*GitWrap) Switch

func (gw *GitWrap) Switch(args ...string) *GitWrap

Switch command for git

func (*GitWrap) Tag

func (gw *GitWrap) Tag(args ...string) *GitWrap

Tag command for git

func (*GitWrap) Var

func (gw *GitWrap) Var(args ...string) *GitWrap

Var command for git

func (*GitWrap) WithArg

func (gw *GitWrap) WithArg(args ...string) *GitWrap

WithArg add args and returns the current object. alias of the WithArg()

func (*GitWrap) WithArgIf

func (gw *GitWrap) WithArgIf(arg string, exprOk bool) *GitWrap

WithArgIf add arg and returns the current object

func (*GitWrap) WithArgf

func (gw *GitWrap) WithArgf(format string, args ...interface{}) *GitWrap

WithArgf add arg and returns the current object. alias of the Argf()

func (*GitWrap) WithArgs

func (gw *GitWrap) WithArgs(args []string) *GitWrap

WithArgs for the git

func (*GitWrap) WithArgsIf

func (gw *GitWrap) WithArgsIf(args []string, exprOk bool) *GitWrap

WithArgsIf add arg and returns the current object

func (*GitWrap) WithFn

func (gw *GitWrap) WithFn(fn func(gw *GitWrap)) *GitWrap

WithFn for setting gw

func (*GitWrap) WithOutput

func (gw *GitWrap) WithOutput(out *os.File, errOut *os.File) *GitWrap

WithOutput returns the current argument

func (*GitWrap) WithStdin

func (gw *GitWrap) WithStdin(in *os.File) *GitWrap

WithStdin returns the current argument

func (*GitWrap) WithWorkDir

func (gw *GitWrap) WithWorkDir(dir string) *GitWrap

WithWorkDir returns the current object

func (*GitWrap) Worktree

func (gw *GitWrap) Worktree(args ...string) *GitWrap

Worktree command for git

type Range

type Range struct {
	A string
	B string
}

Range struct

func NewRange

func NewRange(a, b string) (*Range, error)

NewRange object

func (*Range) IsAncestor

func (r *Range) IsAncestor() bool

IsAncestor check

func (*Range) IsIdentical

func (r *Range) IsIdentical() bool

IsIdentical check

type RemoteInfo

type RemoteInfo struct {
	// Name the repo remote name, default see DefaultRemoteName
	Name string
	// Type remote type. allow: push, fetch
	Type string
	// URL full git remote URL string.
	//
	// eg:
	// - http: "https://github.com/gookit/gitw.git"
	// - git: "git@github.com:gookit/gitw.git"
	URL string

	// Scheme the url scheme. eg: git, http, https
	Scheme string
	// Host name. eg: "github.com"
	Host string
	// the group, repo name
	Group, Repo string

	// Proto the type 'ssh' OR 'http'
	Proto string
}

RemoteInfo struct - http: "https://github.com/gookit/gitw.git" - git: "git@github.com:gookit/gitw.git"

func NewEmptyRemoteInfo

func NewEmptyRemoteInfo(URL string) *RemoteInfo

NewEmptyRemoteInfo only with URL string.

func NewRemoteInfo

func NewRemoteInfo(name, url, typ string) (*RemoteInfo, error)

NewRemoteInfo create

func (*RemoteInfo) GitURL

func (r *RemoteInfo) GitURL() string

GitURL build. eg: "git@github.com:gookit/gitw.git"

func (*RemoteInfo) Invalid

func (r *RemoteInfo) Invalid() bool

Invalid check

func (*RemoteInfo) Path

func (r *RemoteInfo) Path() string

Path string

func (*RemoteInfo) RawURLOfHTTP

func (r *RemoteInfo) RawURLOfHTTP() string

RawURLOfHTTP get, if RemoteInfo.URL is git proto, build an https url.

func (*RemoteInfo) RepoPath

func (r *RemoteInfo) RepoPath() string

RepoPath string

func (*RemoteInfo) String

func (r *RemoteInfo) String() string

String remote info to string.

func (*RemoteInfo) URLOfHTTP

func (r *RemoteInfo) URLOfHTTP() string

URLOfHTTP build

func (*RemoteInfo) URLOfHTTPS

func (r *RemoteInfo) URLOfHTTPS() string

URLOfHTTPS build

func (*RemoteInfo) Valid

func (r *RemoteInfo) Valid() bool

Valid check

type RemoteInfos

type RemoteInfos map[string]*RemoteInfo

RemoteInfos map. key is type name(see RemoteTypePush)

type Repo

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

Repo struct

func NewRepo

func NewRepo(dir string) *Repo

NewRepo create Repo object

func (*Repo) AllRemoteInfos

func (r *Repo) AllRemoteInfos() map[string]RemoteInfos

AllRemoteInfos get

func (*Repo) Cmd

func (r *Repo) Cmd(name string, args ...string) *GitWrap

Cmd new git command wrapper

func (*Repo) CurrentBranch

func (r *Repo) CurrentBranch() string

CurrentBranch return current branch name

func (*Repo) DefaultRemoteInfo

func (r *Repo) DefaultRemoteInfo(typ ...string) *RemoteInfo

DefaultRemoteInfo get

func (*Repo) Dir

func (r *Repo) Dir() string

Dir get repo dir

func (*Repo) Err

func (r *Repo) Err() error

Err get last error

func (*Repo) Git

func (r *Repo) Git() *GitWrap

Git get git wrapper

func (*Repo) HasRemote

func (r *Repo) HasRemote(name string) bool

HasRemote check

func (*Repo) Info

func (r *Repo) Info() *RepoInfo

Info get repo information

func (*Repo) Init

func (r *Repo) Init() error

Init run git init for the repo dir.

func (*Repo) IsInited

func (r *Repo) IsInited() bool

IsInited is init git repo dir

func (*Repo) LargestTag

func (r *Repo) LargestTag() string

LargestTag get max tag version of the repo

func (*Repo) LastAbbrevID

func (r *Repo) LastAbbrevID() string

LastAbbrevID get last abbrev commit ID, len is 7

func (*Repo) LastCommitID

func (r *Repo) LastCommitID() string

LastCommitID value

func (*Repo) MaxTag

func (r *Repo) MaxTag() string

MaxTag get max tag version of the repo

func (*Repo) PrevMaxTag

func (r *Repo) PrevMaxTag() string

PrevMaxTag get second-largest tag of the repo

func (*Repo) RandomRemoteInfo

func (r *Repo) RandomRemoteInfo(typ ...string) *RemoteInfo

RandomRemoteInfo get

func (*Repo) RemoteInfo

func (r *Repo) RemoteInfo(remote string, typ ...string) *RemoteInfo

RemoteInfo get. if typ is empty, will return random type info.

func (*Repo) RemoteInfos

func (r *Repo) RemoteInfos(remote string) RemoteInfos

RemoteInfos get by remote name

func (*Repo) RemoteNames

func (r *Repo) RemoteNames() []string

RemoteNames get

func (*Repo) TagSecondMax

func (r *Repo) TagSecondMax() string

TagSecondMax get second-largest tag of the repo

func (*Repo) Tags

func (r *Repo) Tags() []string

Tags get repo tags list

func (*Repo) TagsSortedByRefName

func (r *Repo) TagsSortedByRefName() []string

TagsSortedByRefName get repo tags list

func (*Repo) WithConfig

func (r *Repo) WithConfig(cfg *RepoConfig) *Repo

WithConfig new repo config

func (*Repo) WithConfigFn

func (r *Repo) WithConfigFn(fn func(cfg *RepoConfig)) *Repo

WithConfigFn new repo config func

func (*Repo) WithFn

func (r *Repo) WithFn(fn func(r *Repo)) *Repo

WithFn new repo self config func

type RepoConfig

type RepoConfig struct {
	DefaultBranch string
	DefaultRemote string
}

RepoConfig struct

type RepoInfo

type RepoInfo struct {
	Name string
	Path string
	Dir  string
	URL  string
	// LastCID value
	LastCID string
	Branch  string
	Version string
}

RepoInfo struct

Directories

Path Synopsis
_examples
chlog command
cmd
chlog command

Jump to

Keyboard shortcuts

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