aboutsummaryrefslogtreecommitdiff
path: root/ref/ref.go
blob: 3752d1e33769aaf17a93bbd7b9022093a663fa58 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Package ref provides general, detached, and symbolic references.
package ref

import "codeberg.org/lindenii/furgit/objectid"

// Ref is a Git reference.
//
// Implementations must be in this package.
type Ref interface {
	isRef()
	Name() string
}

// Detached points directly to an object ID.
type Detached struct {
	RefName string
	ID      objectid.ObjectID

	// Peeled is the peeled target when available (for annotated tags).
	//
	// This field is optional backend-provided metadata. Backends that do not
	// have peel metadata available may leave it nil.
	Peeled *objectid.ObjectID
}

// Name returns the fully-qualified reference name.
func (ref Detached) Name() string {
	return ref.RefName
}

func (Detached) isRef() {}

// Symbolic points to another reference name.
type Symbolic struct {
	RefName string
	Target  string
}

// Name returns the fully-qualified reference name.
func (ref Symbolic) Name() string {
	return ref.RefName
}

func (Symbolic) isRef() {}