@@ -1270,55 +1270,50 @@ func (d *Describe) String() string {
1270
1270
d .Dirty )
1271
1271
}
1272
1272
1273
- func (r * Repository ) Describe (options * DescribeOptions , hashes ... * plumbing.Hash ) ([]Describe , error ) {
1273
+ // Describe just like the `git describe` command will return a Describe struct for the hash passed.
1274
+ // Describe struct implements String interface so it can be easily printed out.
1275
+ func (r * Repository ) Describe (options * DescribeOptions , hash * plumbing.Hash ) (* Describe , error ) {
1276
+
1277
+ // Fetch the reference log
1278
+ commitIterator , err := r .Log (& LogOptions {
1279
+ From : * hash ,
1280
+ Order : LogOrderCommitterTime ,
1281
+ })
1282
+ if err != nil {
1283
+ return nil , err
1284
+ }
1274
1285
1275
- var describes []Describe
1286
+ // Tag map for rapid (?) query
1287
+ tagIterator , err := r .Tags ()
1288
+ if err != nil {
1289
+ return nil , err
1290
+ }
1291
+ tags := make (map [plumbing.Hash ]* plumbing.Reference )
1292
+ tagIterator .ForEach (func (t * plumbing.Reference ) error {
1293
+ tags [t .Hash ()] = t
1294
+ return nil
1295
+ })
1276
1296
1277
- for _ , hash := range hashes {
1278
1297
1279
- // Fetch the reference log
1280
- commitIterator , err := r .Log (& LogOptions {
1281
- From : * hash ,
1282
- Order : LogOrderCommitterTime ,
1283
- })
1284
- if err != nil {
1285
- return nil , err
1298
+ // Search the tag
1299
+ var tag * plumbing.Reference
1300
+ var count int
1301
+ err = commitIterator .ForEach (func (c * object.Commit ) error {
1302
+ if t , ok := tags [c .Hash ]; ok {
1303
+ tag = t
1286
1304
}
1287
-
1288
- // Tag map for rapid (?) query
1289
- tagIterator , err := r .Tags ()
1290
- if err != nil {
1291
- return nil , err
1305
+ if tag != nil {
1306
+ return storer .ErrStop
1292
1307
}
1293
- tags := make (map [plumbing.Hash ]* plumbing.Reference )
1294
- tagIterator .ForEach (func (t * plumbing.Reference ) error {
1295
- tags [t .Hash ()] = t
1296
- return nil
1297
- })
1298
-
1299
-
1300
- // Search the tag
1301
- var tag * plumbing.Reference
1302
- var count int
1303
- err = commitIterator .ForEach (func (c * object.Commit ) error {
1304
- if t , ok := tags [c .Hash ]; ok {
1305
- tag = t
1306
- }
1307
- if tag != nil {
1308
- return storer .ErrStop
1309
- }
1310
- count ++
1311
- return nil
1312
- })
1313
-
1314
- describes = append (describes , Describe {
1315
- hash ,
1316
- tag ,
1317
- count ,
1318
- options .Dirty ,
1319
- })
1308
+ count ++
1309
+ return nil
1310
+ })
1320
1311
1321
- }
1312
+ return & Describe {
1313
+ hash ,
1314
+ tag ,
1315
+ count ,
1316
+ options .Dirty ,
1317
+ }, nil
1322
1318
1323
- return describes , nil
1324
1319
}
0 commit comments