tag

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package tag provides git tag management and semantic versioning.

This package handles tag creation, listing, and semantic version calculations for release management.

Features

  • Tag creation (lightweight and annotated)
  • Tag listing and filtering
  • Semantic version parsing and incrementing
  • Next version suggestions

Usage

manager := tag.NewManager(repoPath)
tags, err := manager.List()
nextVersion := tag.NextVersion(currentVersion, tag.Minor)

Index

Constants

This section is empty.

Variables

View Source
var ErrNoTags = errors.New("no tags found")

ErrNoTags is returned when no tags are found in the repository.

Functions

This section is empty.

Types

type CreateOptions

type CreateOptions struct {
	// Name is the tag name (required)
	Name string

	// Message is the tag message (creates annotated tag if set)
	Message string

	// Sign creates a GPG-signed tag
	Sign bool

	// Force overwrites existing tag
	Force bool

	// Ref is the commit to tag (default: HEAD)
	Ref string
}

CreateOptions configures tag creation.

type DeleteOptions

type DeleteOptions struct {
	// Name is the tag name to delete
	Name string

	// Remote also deletes from remote
	Remote bool
}

DeleteOptions configures tag deletion.

type ListOptions

type ListOptions struct {
	// Pattern filters tags by name pattern
	Pattern string

	// Sort defines sort order: "version" (semver), "date", "name"
	Sort string

	// Limit limits the number of tags returned
	Limit int

	// IncludeRemote includes remote-only tags
	IncludeRemote bool
}

ListOptions configures tag listing.

type Manager

type Manager interface {
	// Create creates a new tag.
	Create(ctx context.Context, repo *repository.Repository, opts CreateOptions) error

	// List returns all tags.
	List(ctx context.Context, repo *repository.Repository, opts ListOptions) ([]*Tag, error)

	// Push pushes tags to remote.
	Push(ctx context.Context, repo *repository.Repository, opts PushOptions) error

	// Delete deletes a tag.
	Delete(ctx context.Context, repo *repository.Repository, opts DeleteOptions) error

	// Exists checks if a tag exists.
	Exists(ctx context.Context, repo *repository.Repository, name string) (bool, error)

	// Latest returns the latest tag by version or date.
	Latest(ctx context.Context, repo *repository.Repository) (*Tag, error)

	// NextVersion suggests the next version based on current tags.
	NextVersion(ctx context.Context, repo *repository.Repository, bump string) (string, error)
}

Manager defines tag operations.

func NewManager

func NewManager() Manager

NewManager creates a new tag manager.

type PushOptions

type PushOptions struct {
	// All pushes all tags
	All bool

	// Name is the specific tag to push
	Name string

	// Remote is the remote to push to (default: origin)
	Remote string

	// Force forces push (overwrites remote)
	Force bool
}

PushOptions configures tag push.

type Tag

type Tag struct {
	// Name is the tag name (e.g., "v1.0.0")
	Name string

	// Ref is the full tag reference (e.g., "refs/tags/v1.0.0")
	Ref string

	// SHA is the commit SHA the tag points to
	SHA string

	// Message is the tag message (for annotated tags)
	Message string

	// Tagger is the person who created the tag
	Tagger string

	// Date is when the tag was created
	Date time.Time

	// IsAnnotated indicates if this is an annotated tag
	IsAnnotated bool

	// IsRemote indicates if this tag exists on remote
	IsRemote bool
}

Tag represents a Git tag.

Jump to

Keyboard shortcuts

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