ReferenceName Class

Summary

Represents a Git reference name in both its canonical (refs/heads/main) and friendly (main) forms.
Assembly
GitVersion.Core.dll
Namespace
GitVersion.Git
Interfaces
Base Types
  • Object
graph BT Type-->Base0["Object"] Type-.->Interface0["IEquatable<ReferenceName>"] Type-.->Interface1["IComparable<ReferenceName>"] Type["ReferenceName"] class Type type-node

Syntax

public sealed class ReferenceName : IEquatable<ReferenceName>, IComparable<ReferenceName>

Attributes

Type Description
NullableContextAttribute
NullableAttribute

Constructors

Name Summary
ReferenceName(string) Initializes a new ReferenceName from its canonical form.

Fields

Name Constant Value Summary
LocalBranchPrefix refs/heads/
The canonical prefix for local branches.
static
RemoteTrackingBranchPrefix refs/remotes/
The canonical prefix for remote-tracking branches.
static

Properties

Name Value Summary
Canonical string
Gets the canonical reference name (e.g. refs/heads/main).
Friendly string
Gets the shortened, human-readable reference name (e.g. main or origin/main).
IsLocalBranch bool
Gets a value indicating whether this is a local branch reference.
IsPullRequest bool
Gets a value indicating whether this reference corresponds to a pull request.
IsRemoteBranch bool
Gets a value indicating whether this is a remote-tracking branch reference.
IsTag bool
Gets a value indicating whether this is a tag reference.
WithoutOrigin string
Gets the friendly name with the origin/ prefix removed for remote-tracking branches.
WithoutRemote string
Gets the friendly name with the remote name removed for remote-tracking branches.

Methods

Name Value Summary
CompareTo(ReferenceName) int
Compares this instance to other by canonical name.
Equals(object) bool
Returns true when obj is a ReferenceName with the same canonical name.
Equals(ReferenceName) bool
Returns true when the canonical name of this instance equals that of other.
EquivalentTo(string) bool
Returns true when name matches any of the canonical, friendly, or origin-stripped forms of this reference.
FromBranchName(string) ReferenceName
Creates a ReferenceName from a branch name, automatically prepending the local-branch prefix when necessary.
static
FromTagName(string) ReferenceName
Creates a ReferenceName from a literal tag name, always prepending refs/tags/.
static
GetHashCode() int
Returns a hash code based on the canonical name.
Parse(string) ReferenceName
Parses canonicalName as a canonical Git reference name, throwing when the input is not a valid canonical form.
static
ToString() string
Returns the friendly (shortened) name of this reference.

Operators

Name Value Summary
operator !=(ReferenceName, ReferenceName) bool
operator <(ReferenceName, ReferenceName) bool
operator <=(ReferenceName, ReferenceName) bool
operator ==(ReferenceName, ReferenceName) bool
operator >(ReferenceName, ReferenceName) bool
operator >=(ReferenceName, ReferenceName) bool

Extension Methods