gitshell

package
v0.0.0-...-e9cf350 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

README

GitShell

Minimal go library to execute git commands from the shell.

Obviously requires to have git on your PATH.

Unlike go-git this will call the git client available with all the quirks in it's current version as well as access to any flags or commands implemented in the library.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GitAdd

func GitAdd(inPath, filePath string) (string, error)

GitAdd adds a change in the working directory to the staging area see https://git-scm.com/docs/git-add for more details

func GitCheckout

func GitCheckout(inPath, commitOrBranch string) (string, error)

GitCheckout lets you navigate between the branches returns the output from git and error object if the command failed. see https://git-scm.com/docs/git-checkout for more details

func GitCommit

func GitCommit(inPath, commitMsg string) (string, error)

GitCommit saves your changes to the local repository see https://git-scm.com/docs/git-commit for more details

func GitCommitMessageFromHash

func GitCommitMessageFromHash(inPath, hash string) (string, error)

GitCommitMessageFromHash returns the commit message from the given commit hash see https://git-scm.com/docs/git-log for more details

func GitFetch

func GitFetch(inPath string) (string, error)

GitFetch does what you think it does

func GitFileDiff

func GitFileDiff(inPath, previousCommit, currentCommit string) (map[string]GitChange, error)

GitFileDiff extracts the map of files and the action that was performed on them: added, modified or delete.

func GitReset

func GitReset(inPath, commit string) (string, error)

GitReset hard reset to a given commit

func GitResolveRevision

func GitResolveRevision(inPath, branch string) (string, error)

GitResolveRevision prints the SHA1 hash given a revision specifier see https://git-scm.com/docs/git-rev-parse for more details

func GitResolveRoot

func GitResolveRoot(inPath string) (string, error)

GitResolveRoot finds the root of a git repo given a path see https://git-scm.com/docs/git-rev-parse#Documentation/git-rev-parse.txt---show-toplevel for more details

Types

type GitChange

type GitChange int

GitChange is an enumeration of possible actions perform on files within a commit.

const (
	// Modified signals that the file was modified
	Modified GitChange = iota
	// Added signals that the file was modified
	Added
	// Deleted signals that the file was modified
	Deleted
)

Jump to

Keyboard shortcuts

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