git

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTag added in v0.1.0

func CreateTag(cfg CreateTagConfig) string

CreateTag creates an annotated git tag locally without pushing to remote. Temporarily modifies git user.name and user.email for the tag, then restores the original configuration. Returns the commit SHA that was tagged. Panics if the tag already exists locally or if validation fails.

func InClone

func InClone(repo, ref string, fn func())

InClone performs a shallow clone of the repository at the specified ref into a temporary directory, runs the provided function, then cleans up. Useful for operations that need to work with a specific version of a repo without affecting the current working directory.

func PushTag added in v0.1.0

func PushTag(cfg PushTagConfig)

PushTag pushes an existing local tag to the remote. The credential in cfg selects the transport: a DeployKey pushes via SSH, a TagToken pushes via HTTPS. Exactly one must be set (enforced by PushTagConfig.validate). Panics if the tag doesn't exist locally or already exists on the remote.

func Revision

func Revision() string

Revision returns the short commit SHA of HEAD.

func Root

func Root() string

Root returns the root directory of the git repository by searching upward for a .git directory. Panics if no .git directory is found.

Types

type CreateTagConfig added in v0.1.0

type CreateTagConfig struct {
	// Tag is the tag name (e.g., "v1.2.3"). Must start with alphanumeric,
	// cannot contain ".." or end with ".lock".
	Tag string
	// TagMessage is the annotation message for the tag.
	TagMessage string
	// GitUserName is the name to use for git user.name during tag creation.
	GitUserName string
	// GitUserEmail is the email to use for git user.email during tag creation.
	GitUserEmail string
}

CreateTagConfig contains configuration for creating a local git tag.

type PushTagConfig added in v0.1.0

type PushTagConfig struct {
	// Tag is the tag name to push (must already exist locally).
	Tag string
	// DeployKey is the PEM-formatted SSH private key for authentication.
	// Must include "-----BEGIN" and "-----END" markers. Mutually exclusive with TagToken.
	DeployKey string
	// TagToken is the GitHub token used as the HTTPS password. It is never
	// included in command-line arguments, git config, or remote URLs.
	// Mutually exclusive with DeployKey.
	TagToken string
	// Repository is the GitHub repository in "owner/repo" format.
	Repository string
}

PushTagConfig contains configuration for pushing a tag to a remote. Exactly one of DeployKey or TagToken must be set; that choice determines whether the push uses SSH (deploy key) or HTTPS (GitHub token).

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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