Class: DurableHuggingfaceHub::Types::GitRefInfo

Inherits:
Struct
  • Object
show all
Includes:
Loadable
Defined in:
lib/durable_huggingface_hub/types/commit_info.rb

Overview

Information about a Git reference (branch or tag) in a HuggingFace Hub repository.

Examples:

Creating a GitRefInfo from API response

ref_info = GitRefInfo.from_hash({
  "name" => "main",
  "ref" => "refs/heads/main",
  "targetCommit" => "a1b2c3d4e5f6..."
})

Accessing ref information

ref_info.name           # => "main"
ref_info.target_commit  # => "a1b2c3d4e5f6..."

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameString (readonly)

Returns Reference name (e.g., “main”, “v1.0.0”).

Returns:

  • (String)

    Reference name (e.g., “main”, “v1.0.0”)



97
# File 'lib/durable_huggingface_hub/types/commit_info.rb', line 97

attribute :name, Types::String

#refString (readonly)

Returns Full reference path (e.g., “refs/heads/main”).

Returns:

  • (String)

    Full reference path (e.g., “refs/heads/main”)



101
# File 'lib/durable_huggingface_hub/types/commit_info.rb', line 101

attribute :ref, Types::String

#target_commitString? (readonly)

Returns Target commit OID.

Returns:

  • (String, nil)

    Target commit OID



105
# File 'lib/durable_huggingface_hub/types/commit_info.rb', line 105

attribute :target_commit, Types::OptionalString.default(nil)

Instance Method Details

#branch?Boolean

Checks if this is a branch reference.

Returns:

  • (Boolean)

    True if branch



112
113
114
# File 'lib/durable_huggingface_hub/types/commit_info.rb', line 112

def branch?
  ref.start_with?("refs/heads/")
end

#inspectString

Returns a detailed inspection string.

Returns:

  • (String)

    Inspection string



143
144
145
146
# File 'lib/durable_huggingface_hub/types/commit_info.rb', line 143

def inspect
  "#<#{self.class.name} name=#{name.inspect} type=#{ref_type} " \
    "commit=#{target_commit&.[](0, 7).inspect}>"
end

#ref_typeString

Returns the reference type.

Returns:

  • (String)

    “branch”, “tag”, or “unknown”



126
127
128
129
130
131
# File 'lib/durable_huggingface_hub/types/commit_info.rb', line 126

def ref_type
  return "branch" if branch?
  return "tag" if tag?

  "unknown"
end

#tag?Boolean

Checks if this is a tag reference.

Returns:

  • (Boolean)

    True if tag



119
120
121
# File 'lib/durable_huggingface_hub/types/commit_info.rb', line 119

def tag?
  ref.start_with?("refs/tags/")
end

#to_sString

Returns a short description of the ref.

Returns:

  • (String)

    Description string



136
137
138
# File 'lib/durable_huggingface_hub/types/commit_info.rb', line 136

def to_s
  "#{ref_type}: #{name}"
end