Skip to content

Commit 1f8e51e

Browse files
authored
Merge pull request #331 from vmarkovtsev/master
Fix --head with siva files
2 parents 5c8215d + 87fd4b9 commit 1f8e51e

File tree

2 files changed

+26
-30
lines changed

2 files changed

+26
-30
lines changed

internal/core/pipeline.go

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -450,33 +450,14 @@ func (pipeline *Pipeline) Len() int {
450450
func (pipeline *Pipeline) Commits(firstParent bool) ([]*object.Commit, error) {
451451
var result []*object.Commit
452452
repository := pipeline.repository
453-
head, err := repository.Head()
453+
heads, err := pipeline.HeadCommit()
454454
if err != nil {
455-
if err == plumbing.ErrReferenceNotFound {
456-
refs, errr := repository.References()
457-
if errr != nil {
458-
return nil, errors.Wrap(errr, "unable to list the references")
459-
}
460-
refs.ForEach(func(ref *plumbing.Reference) error {
461-
if strings.HasPrefix(ref.Name().String(), "refs/heads/HEAD/") {
462-
head = ref
463-
return storer.ErrStop
464-
}
465-
return nil
466-
})
467-
}
468-
if head == nil && err != nil {
469-
return nil, errors.Wrap(err, "unable to collect the commit history")
470-
}
455+
return nil, err
471456
}
472-
457+
head := heads[0]
473458
if firstParent {
474-
commit, err := repository.CommitObject(head.Hash())
475-
if err != nil {
476-
panic(err)
477-
}
478459
// the first parent matches the head
479-
for ; err != io.EOF; commit, err = commit.Parents().Next() {
460+
for commit := head; err != io.EOF; commit, err = commit.Parents().Next() {
480461
if err != nil {
481462
panic(err)
482463
}
@@ -488,26 +469,41 @@ func (pipeline *Pipeline) Commits(firstParent bool) ([]*object.Commit, error) {
488469
}
489470
return result, nil
490471
}
491-
cit, err := repository.Log(&git.LogOptions{From: head.Hash()})
472+
cit, err := repository.Log(&git.LogOptions{From: head.Hash})
492473
if err != nil {
493474
return nil, errors.Wrap(err, "unable to collect the commit history")
494475
}
495476
defer cit.Close()
496-
cit.ForEach(func(commit *object.Commit) error {
477+
err = cit.ForEach(func(commit *object.Commit) error {
497478
result = append(result, commit)
498479
return nil
499480
})
500-
return result, nil
481+
return result, err
501482
}
502483

503484
// HeadCommit returns the latest commit in the repository (HEAD).
504485
func (pipeline *Pipeline) HeadCommit() ([]*object.Commit, error) {
505486
repository := pipeline.repository
506-
headref, err := repository.Head()
487+
head, err := repository.Head()
507488
if err != nil {
508-
return nil, err
489+
if err == plumbing.ErrReferenceNotFound {
490+
refs, errr := repository.References()
491+
if errr != nil {
492+
return nil, errors.Wrap(errr, "unable to list the references")
493+
}
494+
err = refs.ForEach(func(ref *plumbing.Reference) error {
495+
if strings.HasPrefix(ref.Name().String(), "refs/heads/HEAD/") {
496+
head = ref
497+
return storer.ErrStop
498+
}
499+
return nil
500+
})
501+
}
502+
}
503+
if head == nil {
504+
return nil, errors.Wrap(err, "unable to find the head reference")
509505
}
510-
commit, err := repository.CommitObject(headref.Hash())
506+
commit, err := repository.CommitObject(head.Hash())
511507
if err != nil {
512508
return nil, err
513509
}

python/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
description="Python companion for github.com/src-d/hercules to visualize the results.",
2323
long_description=long_description,
2424
long_description_content_type="text/markdown",
25-
version="10.6.0",
25+
version="10.6.1",
2626
license="Apache-2.0",
2727
author="source{d}",
2828
author_email="machine-learning@sourced.tech",

0 commit comments

Comments
 (0)