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

Commit 0605454

Browse files
author
Eduardo Lezcano
committedApr 20, 2018
Moved options to the options.go file
Signed-off-by: Eduardo Lezcano <eduardo.lezcano@be.atlascopco.com>
1 parent 77128e9 commit 0605454

File tree

2 files changed

+35
-29
lines changed

2 files changed

+35
-29
lines changed
 

‎options.go

+30
Original file line numberDiff line numberDiff line change
@@ -431,3 +431,33 @@ type PlainOpenOptions struct {
431431

432432
// Validate validates the fields and sets the default values.
433433
func (o *PlainOpenOptions) Validate() error { return nil }
434+
435+
// DescribeOptions as defined by `git describe`
436+
type DescribeOptions struct {
437+
// Contains find the tag that comes after the commit
438+
//Contains bool
439+
// Debug search strategy on stderr
440+
//Debug bool
441+
// All Use any reference
442+
//All bool
443+
// Tags use any tag, even unannotated
444+
//Tags bool
445+
// FirstParent only follow first parent
446+
//FirstParent bool
447+
// Use <Abbrev> digits to display SHA-1s
448+
// By default is 8
449+
//Abbrev int
450+
// Only output exact matches
451+
//ExactMatch bool
452+
// Consider <Candidates> most recent tags
453+
// By default is 10
454+
//Candidates int
455+
// Only consider tags matching <Match> pattern
456+
//Match string
457+
// Show abbreviated commit object as fallback
458+
//Always bool
459+
// Append <mark> on dirty working tree (default: "-dirty")
460+
Dirty string
461+
}
462+
463+
func (o *DescribeOptions) Validate() error { return nil }

‎repository.go

+5-29
Original file line numberDiff line numberDiff line change
@@ -1224,33 +1224,6 @@ func (r *Repository) createNewObjectPack(cfg *RepackConfig) (h plumbing.Hash, er
12241224
return h, err
12251225
}
12261226

1227-
type DescribeOptions struct {
1228-
// Contains find the tag that comes after the commit
1229-
//Contains bool
1230-
// Debug search strategy on stderr
1231-
//Debug bool
1232-
// All Use any reference
1233-
//All bool
1234-
// Tags use any tag, even unannotated
1235-
//Tags bool
1236-
// FirstParent only follow first parent
1237-
//FirstParent bool
1238-
// Use <Abbrev> digits to display SHA-1s
1239-
// By default is 8
1240-
//Abbrev int
1241-
// Only output exact matches
1242-
//ExactMatch bool
1243-
// Consider <Candidates> most recent tags
1244-
// By default is 10
1245-
//Candidates int
1246-
// Only consider tags matching <Match> pattern
1247-
//Match string
1248-
// Show abbreviated commit object as fallback
1249-
//Always bool
1250-
// Append <mark> on dirty working tree (default: "-dirty")
1251-
Dirty string
1252-
}
1253-
12541227
type Describe struct {
12551228
// Reference being described
12561229
Reference *plumbing.Reference
@@ -1272,7 +1245,10 @@ func (d *Describe) String() string {
12721245

12731246
// Describe just like the `git describe` command will return a Describe struct for the hash passed.
12741247
// Describe struct implements String interface so it can be easily printed out.
1275-
func (r *Repository) Describe(ref *plumbing.Reference, options *DescribeOptions) (*Describe, error) {
1248+
func (r *Repository) Describe(ref *plumbing.Reference, opts *DescribeOptions) (*Describe, error) {
1249+
if err := opts.Validate(); err != nil {
1250+
return nil, err
1251+
}
12761252

12771253
// Fetch the reference log
12781254
commitIterator, err := r.Log(&LogOptions{
@@ -1313,7 +1289,7 @@ func (r *Repository) Describe(ref *plumbing.Reference, options *DescribeOptions)
13131289
ref,
13141290
tag,
13151291
count,
1316-
options.Dirty,
1292+
opts.Dirty,
13171293
}, nil
13181294

13191295
}

0 commit comments

Comments
 (0)