githelpers

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsReadOnlyGitCommand

func IsReadOnlyGitCommand(command string) bool

Types

type CommandType

type CommandType int
const (
	UnknownCommand CommandType = iota
	Porcelain
	Plumbing
	Custom
)

func (CommandType) String

func (ct CommandType) String() string

type GitCommand

type GitCommand struct {
	Name          string      // e.g. "branch"
	Args          []string    // flags and operands
	Valid         bool        // was Name in our lookup?
	Type          CommandType // Porcelain, Plumbing, or Unknown
	IsReadOnly    bool
	ValidationErr error // any parse / lookup error
}

GitCommand represents a parsed "git …" invocation.

func ParseGitCommand

func ParseGitCommand(raw string) *GitCommand

ParseGitCommand parses a git command string into a GitCommand struct.

type H

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

H is the struct for wrapping git helper functions It holds repoDir where commands are executed.

func NewGitHelper

func NewGitHelper(repoDirArg ...string) *H

NewGitHelper creates a new GitHelper instance.

func (*H) GetCurrentGitRef

func (h *H) GetCurrentGitRef() (string, error)

GetCurrentGitRef returns the current ref (branch, tag, commit hash) in the repository.

func (*H) GetRepoGitDir

func (h *H) GetRepoGitDir() (string, error)

GetRepoGitDir returns the path to the .git directory of current repository.

func (*H) GitOutput

func (h *H) GitOutput(subCmd string, args ...string) (string, error)

GitOutput executes a git command and returns its output as string.

func (*H) GitRun

func (h *H) GitRun(subCmd string, args ...string) error

GitRun executes a git command without output (via Run).

Jump to

Keyboard shortcuts

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