Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 77128e9

Browse files
author
Eduardo Lezcano
committed
Using the reference instead of the hash to describe
Signed-off-by: Eduardo Lezcano <[email protected]>
1 parent 4fea552 commit 77128e9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

repository.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ type DescribeOptions struct {
12531253

12541254
type Describe struct {
12551255
// Reference being described
1256-
Hash *plumbing.Hash
1256+
Reference *plumbing.Reference
12571257
// Tag of the describe object
12581258
Tag *plumbing.Reference
12591259
// Distance to the tag object in commits
@@ -1266,17 +1266,17 @@ func (d *Describe) String() string {
12661266
return fmt.Sprintf("%v-%v-%v-%v",
12671267
d.Tag.Name().Short(),
12681268
d.Distance,
1269-
d.Hash.String()[0:8],
1269+
d.Reference.Hash().String()[0:8],
12701270
d.Dirty)
12711271
}
12721272

12731273
// Describe just like the `git describe` command will return a Describe struct for the hash passed.
12741274
// Describe struct implements String interface so it can be easily printed out.
1275-
func (r *Repository) Describe(options *DescribeOptions, hash *plumbing.Hash) (*Describe, error) {
1275+
func (r *Repository) Describe(ref *plumbing.Reference, options *DescribeOptions) (*Describe, error) {
12761276

12771277
// Fetch the reference log
12781278
commitIterator, err := r.Log(&LogOptions{
1279-
From: *hash,
1279+
From: ref.Hash(),
12801280
Order: LogOrderCommitterTime,
12811281
})
12821282
if err != nil {
@@ -1310,7 +1310,7 @@ func (r *Repository) Describe(options *DescribeOptions, hash *plumbing.Hash) (*D
13101310
})
13111311

13121312
return &Describe{
1313-
hash,
1313+
ref,
13141314
tag,
13151315
count,
13161316
options.Dirty,

0 commit comments

Comments
 (0)