Class: Git::Commands::Tag::Create Private

Inherits:
Base
  • Object
show all
Defined in:
lib/git/commands/tag/create.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Note:

arguments block audited against https://git-scm.com/docs/git-tag/2.53.0

Implements the git tag command for creating new tags

This command creates a new tag reference pointing at the current HEAD or a specified commit/object.

Examples:

Create a lightweight tag

create = Git::Commands::Tag::Create.new(execution_context)
create.call('v1.0.0')

Create an annotated tag

create = Git::Commands::Tag::Create.new(execution_context)
create.call('v1.0.0', message: 'Release version 1.0.0')

Create a signed tag at a specific commit

create = Git::Commands::Tag::Create.new(execution_context)
create.call('v1.0.0', 'abc123', sign: true, message: 'Signed release')

Force replace an existing tag

create = Git::Commands::Tag::Create.new(execution_context)
create.call('v1.0.0', force: true)

See Also:

Instance Method Summary collapse

Methods inherited from Base

allow_exit_status, arguments, #initialize, requires_git_version, skip_version_validation

Constructor Details

This class inherits a constructor from Git::Commands::Base

Instance Method Details

#call(tagname, commit = nil, **options) ⇒ Git::CommandLineResult

Execute the git tag command to create a new tag

Returns the result of calling git tag.

Parameters:

  • tagname (String)

    the name of the tag to create

  • commit (String, nil) (defaults to: nil)

    the commit, branch, or object to tag

    Defaults to HEAD when omitted.

  • options (Hash)

    command options

Options Hash (**options):

  • :annotate (Boolean, nil) — default: nil

    make an unsigned, annotated tag object

    Requires a message via :message or :file.

    Alias: :a

  • :sign (Boolean, nil) — default: nil

    make a GPG-signed tag using the default signing key (--sign)

    Requires a message via :message or :file.

    Alias: :s

  • :no_sign (Boolean, nil) — default: nil

    override tag.gpgSign config to disable signing (--no-sign)

  • :local_user (String) — default: nil

    make a cryptographically signed tag using the given key

    Requires a message via :message or :file.

    Alias: :u

  • :force (Boolean, nil) — default: nil

    replace an existing tag with the given name instead of failing

    Alias: :f

  • :message (String) — default: nil

    use the given message as the tag message

    Implies --annotate if none of --annotate, --sign, or --local-user is given.

    Alias: :m

  • :file (String) — default: nil

    take the tag message from the given file

    Use - to read from standard input. Implies --annotate if none of --annotate, --sign, or --local-user is given.

    Alias: :F

  • :edit (Boolean, nil) — default: nil

    open an editor to further edit the tag message (--edit)

    Alias: :e

  • :no_edit (Boolean, nil) — default: nil

    suppress the editor (--no-edit)

  • :trailer (Hash, Array<Array>) — default: nil

    add trailers to the tag message

    Can be a Hash { 'Key' => 'value' } or Array of pairs [['Key', 'value']]. Multiple trailers can be specified.

  • :cleanup (String) — default: nil

    set how the tag message is cleaned up

    Must be one of: verbatim (no changes), whitespace (remove leading/trailing whitespace lines), or strip (remove whitespace and commentary). Default is strip.

  • :create_reflog (Boolean, nil) — default: nil

    create a reflog for the tag

    Enables date-based sha1 expressions such as tag@{yesterday}.

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (Git::FailedError)

    if git exits with a non-zero exit status



# File 'lib/git/commands/tag/create.rb', line 57