Class: Git::StashInfo

Inherits:
Data
  • Object
show all
Defined in:
lib/git/stash_info.rb

Overview

Immutable value object representing stash entry information

StashInfo encapsulates the parsed data from git stash list output. Each entry contains comprehensive information about the stash including its index, reference name, commit SHA, branch, message, and the author and committer identities.

The author and committer are nested AuthorInfo values. Their date is a Time parsed from git's ISO 8601 output, not an ISO 8601 string.

Examples:

Create a StashInfo from parsed stash list output

info = Git::StashInfo.new(
  index: 0,
  name: 'stash@{0}',
  oid: 'abc123def456789...',
  short_oid: 'abc123d',
  branch: 'main',
  message: 'WIP on main: abc123 Initial commit',
  author: Git::AuthorInfo.new(
    name: 'Jane Doe',
    email: '[email protected]',
    date: Time.iso8601('2026-01-24T10:30:00-08:00')
  ),
  committer: Git::AuthorInfo.new(
    name: 'Jane Doe',
    email: '[email protected]',
    date: Time.iso8601('2026-01-24T10:30:00-08:00')
  )
)

info.index           # => 0
info.name            # => 'stash@{0}'
info.oid             # => 'abc123def456789...'
info.short_oid       # => 'abc123d'
info.branch          # => 'main'
info.message         # => 'WIP on main: abc123 Initial commit'
info.author.name     # => 'Jane Doe'
info.author.email    # => '[email protected]'
info.author.date     # => 2026-01-24 10:30:00 -0800
info.committer.name  # => 'Jane Doe'

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authorGit::AuthorInfo (readonly)

The identity of the stash author; the nested date is a Time.

Returns:



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/git/stash_info.rb', line 82

StashInfo = Data.define(
  :index,
  :name,
  :oid,
  :short_oid,
  :branch,
  :message,
  :author,
  :committer
) do
  # Returns the stash reference name
  #
  # @example Convert to string
  #   info.to_s # => 'stash@{0}'
  #
  # @return [String] the stash name (e.g., 'stash@\\{0}')
  def to_s
    name
  end
end

#branchString? (readonly)

Returns the branch name where the stash was created, or nil for custom stash messages.

Returns:

  • (String, nil)

    the branch name where the stash was created, or nil for custom stash messages



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/git/stash_info.rb', line 82

StashInfo = Data.define(
  :index,
  :name,
  :oid,
  :short_oid,
  :branch,
  :message,
  :author,
  :committer
) do
  # Returns the stash reference name
  #
  # @example Convert to string
  #   info.to_s # => 'stash@{0}'
  #
  # @return [String] the stash name (e.g., 'stash@\\{0}')
  def to_s
    name
  end
end

#committerGit::AuthorInfo (readonly)

The identity of the stash committer; the nested date is a Time.

Returns:



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/git/stash_info.rb', line 82

StashInfo = Data.define(
  :index,
  :name,
  :oid,
  :short_oid,
  :branch,
  :message,
  :author,
  :committer
) do
  # Returns the stash reference name
  #
  # @example Convert to string
  #   info.to_s # => 'stash@{0}'
  #
  # @return [String] the stash name (e.g., 'stash@\\{0}')
  def to_s
    name
  end
end

#indexInteger (readonly)

Returns the stash index (0, 1, 2, ...).

Returns:

  • (Integer)

    the stash index (0, 1, 2, ...)



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/git/stash_info.rb', line 82

StashInfo = Data.define(
  :index,
  :name,
  :oid,
  :short_oid,
  :branch,
  :message,
  :author,
  :committer
) do
  # Returns the stash reference name
  #
  # @example Convert to string
  #   info.to_s # => 'stash@{0}'
  #
  # @return [String] the stash name (e.g., 'stash@\\{0}')
  def to_s
    name
  end
end

#messageString (readonly)

Returns the stash message (e.g., 'WIP on main: abc123 commit msg').

Returns:

  • (String)

    the stash message (e.g., 'WIP on main: abc123 commit msg')



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/git/stash_info.rb', line 82

StashInfo = Data.define(
  :index,
  :name,
  :oid,
  :short_oid,
  :branch,
  :message,
  :author,
  :committer
) do
  # Returns the stash reference name
  #
  # @example Convert to string
  #   info.to_s # => 'stash@{0}'
  #
  # @return [String] the stash name (e.g., 'stash@\\{0}')
  def to_s
    name
  end
end

#nameString (readonly)

Returns the stash reference name (e.g., 'stash@{0\}').

Returns:

  • (String)

    the stash reference name (e.g., 'stash@{0\}')



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/git/stash_info.rb', line 82

StashInfo = Data.define(
  :index,
  :name,
  :oid,
  :short_oid,
  :branch,
  :message,
  :author,
  :committer
) do
  # Returns the stash reference name
  #
  # @example Convert to string
  #   info.to_s # => 'stash@{0}'
  #
  # @return [String] the stash name (e.g., 'stash@\\{0}')
  def to_s
    name
  end
end

#oidString (readonly)

Returns the full 40-character object identifier of the stash.

Returns:

  • (String)

    the full 40-character object identifier of the stash



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/git/stash_info.rb', line 82

StashInfo = Data.define(
  :index,
  :name,
  :oid,
  :short_oid,
  :branch,
  :message,
  :author,
  :committer
) do
  # Returns the stash reference name
  #
  # @example Convert to string
  #   info.to_s # => 'stash@{0}'
  #
  # @return [String] the stash name (e.g., 'stash@\\{0}')
  def to_s
    name
  end
end

#short_oidString (readonly)

Returns the abbreviated object identifier (typically 7 characters).

Returns:

  • (String)

    the abbreviated object identifier (typically 7 characters)



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/git/stash_info.rb', line 82

StashInfo = Data.define(
  :index,
  :name,
  :oid,
  :short_oid,
  :branch,
  :message,
  :author,
  :committer
) do
  # Returns the stash reference name
  #
  # @example Convert to string
  #   info.to_s # => 'stash@{0}'
  #
  # @return [String] the stash name (e.g., 'stash@\\{0}')
  def to_s
    name
  end
end

Instance Method Details

#to_sString

Returns the stash reference name

Examples:

Convert to string

info.to_s # => 'stash@{0}'

Returns:

  • (String)

    the stash name (e.g., 'stash@{0}')



98
99
100
# File 'lib/git/stash_info.rb', line 98

def to_s
  name
end