Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 030324a

Browse files
author
Eduardo Lezcano
committed
Improved Describe.String()
Signed-off-by: Eduardo Lezcano <eduardo.lezcano@be.atlascopco.com>
1 parent 0605454 commit 030324a

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

‎repository.go‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,14 +1233,25 @@ type Describe struct {
12331233
Distance int
12341234
// Dirty string to append
12351235
Dirty string
1236+
// Use <Abbrev> digits to display SHA-ls
1237+
Abbrev int
12361238
}
12371239

12381240
func (d *Describe) String() string {
1239-
return fmt.Sprintf("%v-%v-%v-%v",
1240-
d.Tag.Name().Short(),
1241-
d.Distance,
1242-
d.Reference.Hash().String()[0:8],
1243-
d.Dirty)
1241+
var s []string
1242+
1243+
if d.Tag != nil{
1244+
s = append(s, d.Tag.Name().Short())
1245+
}
1246+
if d.Distance > 0 {
1247+
s = append(s, fmt.Sprint(d.Distance))
1248+
}
1249+
s = append(s, d.Reference.Hash().String()[0:d.Abbrev])
1250+
if d.Dirty != "" {
1251+
s = append(s, d.Dirty)
1252+
}
1253+
1254+
return strings.Join(s, "-")
12441255
}
12451256

12461257
// Describe just like the `git describe` command will return a Describe struct for the hash passed.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /