types

package
v0.0.0-...-0ddc8dd Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefaultExecutor

func SetDefaultExecutor(exec Executor)

Types

type Cmd

type Cmd struct {
	Debug    bool
	Command  string
	Options  []string
	Executor Executor
}

func NewCmd

func NewCmd(name string) *Cmd

func (*Cmd) AddOption

func (g *Cmd) AddOption(option string)

func (*Cmd) AddOptions

func (g *Cmd) AddOptions(options ...Option)

func (*Cmd) Exec

func (g *Cmd) Exec(ctx context.Context, name string, debug bool, args ...string) (string, error)

type Commit

type Commit struct {
	Hash    string
	Names   string
	Date    string
	Author  string
	Subject string
	Body    string
}

func CreateCommitFromXML

func CreateCommitFromXML(xml *XmlCommit) *Commit

type CommitMessage

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

CommitMessage represents a git commit message You can access the message's Subject and Body

func NewCommitMessage

func NewCommitMessage(msg string, commentChar string) *CommitMessage

NewCommitMessage is the CommitMessage struct constructor

func NewCommitMessageFromFile

func NewCommitMessageFromFile(file, commentChar string) (*CommitMessage, error)

NewCommitMessageFromFile creates a CommitMessage struct by reading the contents a file

func (*CommitMessage) Body

func (m *CommitMessage) Body() string

Body returns a string starting from line 3

func (*CommitMessage) BodyLines

func (m *CommitMessage) BodyLines() []string

BodyLines returns all lines starting from line 3

func (*CommitMessage) CommentChar

func (m *CommitMessage) CommentChar() string

CommentChar returns the configured comment character, default is `#`

func (*CommitMessage) IsEmpty

func (m *CommitMessage) IsEmpty() bool

IsEmpty returns true if the commit message does not have any content

func (*CommitMessage) IsFixup

func (m *CommitMessage) IsFixup() bool

IsFixup indicates if a commit is a `--fixup` commit

func (*CommitMessage) IsSquash

func (m *CommitMessage) IsSquash() bool

IsSquash indicates if a commit is a `--squash` commit

func (*CommitMessage) Lines

func (m *CommitMessage) Lines() []string

Lines returns all lines except comment lines

func (*CommitMessage) Message

func (m *CommitMessage) Message() string

Message returns the commit message without comments

func (*CommitMessage) Raw

func (m *CommitMessage) Raw() string

Raw returns the raw content of the commit message with comments and everything

func (*CommitMessage) Subject

func (m *CommitMessage) Subject() string

Subject returns the first line of the commit message

type Executor

type Executor func(ctx context.Context, name string, debug bool, args ...string) (string, error)

type FileList

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

func (*FileList) All

func (f *FileList) All() []string

func (*FileList) OfType

func (f *FileList) OfType(suffix string) []string

type Option

type Option func(g *Cmd)

type Range

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

func NewRange

func NewRange(from *Ref, to *Ref) *Range

func (*Range) From

func (r *Range) From() *Ref

func (*Range) To

func (r *Range) To() *Ref

type Ref

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

func NewRef

func NewRef(id, hash, branch string) *Ref

func (*Ref) Branch

func (r *Ref) Branch() string

func (*Ref) Hash

func (r *Ref) Hash() string

func (*Ref) Id

func (r *Ref) Id() string

type XmlCommit

type XmlCommit struct {
	XMLName xml.Name `xml:"commit"`
	Hash    string   `xml:"hash"`
	Names   string   `xml:"names"`
	Date    string   `xml:"date"`
	Author  string   `xml:"author"`
	Subject string   `xml:"subject"`
	Body    string   `xml:"body"`
}

XmlCommit is used to represent commits in a commit log

type XmlLog

type XmlLog struct {
	XMLName xml.Name     `xml:"log"`
	Commits []*XmlCommit `xml:"commit"`
}

XmlLog is used to read commit messages from the git log Via log --format the log command creates xml output that can be parsed into these structs. XmlLog being just the container for the list of XmlCommit structs

<commit>
  <hash>55d061</hash>
  <names><![CDATA[head]]></names>
  <date>2023-04-23</date>
  <author><![CDATA[Sebastian Feldmann <sf@sebastian-feldmann.info>]]></author>
  <subject><![CDATA[Fix example docs]]></subject>
  <body><![CDATA[]]></body>
</commit>

func ParseLogXml

func ParseLogXml(out string) (XmlLog, error)

ParseLogXml is used to read infos from the git log

Jump to

Keyboard shortcuts

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