git

package
v0.0.0-...-caab886 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MODIFIED changeKind = iota
	ADDED
	DELETED
	RENAMED
	COPIED
	TYPE
	UNMERGED
	CHANGE_KIND_COUNT
)

Variables

This section is empty.

Functions

func Checkout

func Checkout(userArgs []string)

func Diff

func Diff()

func ExtractUniqueRemotes

func ExtractUniqueRemotes(dirs []string) (map[string]string, []string)

ExtractUniqueRemotes takes a list of directories and returns: - a map of dir -> SSH destination (only for dirs with SSH remotes) - a deduplicated slice of unique SSH destinations

func GetBranchRemoteURL

func GetBranchRemoteURL(dir string, branch string) (string, error)

GetBranchRemoteURL returns the remote URL for the given branch in the repo at dir. It first looks up the remote name configured for the branch, falling back to "origin". Then it resolves that remote name to a URL.

func GetCurrentBranch

func GetCurrentBranch(dir string) (string, error)

GetCurrentBranch returns the current branch name for the repo at dir.

func GitSSHCommand

func GitSSHCommand(socketPath string) string

GitSSHCommand returns the GIT_SSH_COMMAND value that will use the given socket.

func Interactive

func Interactive()

func ParseSSHDestination

func ParseSSHDestination(remoteURL string) (string, bool)

ParseSSHDestination extracts the SSH destination (e.g. "git@github.com") from a remote URL matching the pattern <user>@<host>:<repo>. Returns the destination and true if it matches, or empty string and false otherwise.

func Pull

func Pull(userArgs []string, mux bool, muxN int)

func Push

func Push(userArgs []string, mux bool, muxN int)

func Status

func Status()

Types

type MuxSockets

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

MuxSockets holds the mapping of SSH destination -> socket path and manages cleanup of the ControlMaster connections.

func EstablishMasters

func EstablishMasters(destinations []string) (*MuxSockets, error)

EstablishMasters creates a ControlMaster connection for each SSH destination. Stdin/stdout/stderr are connected to the terminal so PIN prompts work. Returns an error immediately if any master fails to establish.

func (*MuxSockets) Close

func (m *MuxSockets) Close()

Close tears down all ControlMaster connections and removes the socket directory.

func (*MuxSockets) Get

func (m *MuxSockets) Get(destination string) (string, bool)

Get returns the socket path for the given SSH destination, if any.

type MuxState

type MuxState struct {
	Sockets  *MuxSockets
	DirToSSH map[string]string
	Sem      chan struct{}
}

MuxState holds everything needed to apply multiplexing to git commands.

func InitMux

func InitMux(dirs []string, maxConcurrent int) (*MuxState, error)

InitMux sets up SSH multiplexing for the given directories. The caller must defer MuxState.Sockets.Close().

func (*MuxState) Acquire

func (m *MuxState) Acquire() func()

Acquire takes a semaphore slot, blocking if at capacity. Returns a release function to be deferred.

func (*MuxState) ApplyToCmd

func (m *MuxState) ApplyToCmd(cmd *exec.Cmd, dir string)

ApplyToCmd sets GIT_SSH_COMMAND on the exec.Cmd if the dir has a multiplexed SSH remote.

func (*MuxState) Close

func (m *MuxState) Close()

Close tears down all ControlMaster connections.

Jump to

Keyboard shortcuts

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