You've already forked go-semantic-release
Merge pull request #46 from Nightapes/fix/commits
refactor(internal/git): revert list commits changes
This commit is contained in:
@@ -134,7 +134,7 @@ func (g *GitUtil) GetCommits(lastTagHash string) ([]shared.Commit, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var commits []shared.Commit
|
commits := make(map[string]shared.Commit)
|
||||||
var foundEnd bool
|
var foundEnd bool
|
||||||
|
|
||||||
err = cIter.ForEach(func(c *object.Commit) error {
|
err = cIter.ForEach(func(c *object.Commit) error {
|
||||||
@@ -147,55 +147,25 @@ func (g *GitUtil) GetCommits(lastTagHash string) ([]shared.Commit, error) {
|
|||||||
|
|
||||||
if !foundEnd {
|
if !foundEnd {
|
||||||
log.Tracef("Found commit with hash %s", c.Hash.String())
|
log.Tracef("Found commit with hash %s", c.Hash.String())
|
||||||
commit := shared.Commit{
|
commits[c.Hash.String()] = shared.Commit{
|
||||||
Message: c.Message,
|
Message: c.Message,
|
||||||
Author: c.Committer.Name,
|
Author: c.Committer.Name,
|
||||||
Hash: c.Hash.String(),
|
Hash: c.Hash.String(),
|
||||||
}
|
}
|
||||||
commits = append(commits, commit)
|
|
||||||
|
|
||||||
if len(c.ParentHashes) == 2 {
|
|
||||||
parent, err := g.Repository.CommitObject(c.ParentHashes[1])
|
|
||||||
if err == nil {
|
|
||||||
commit := shared.Commit{
|
|
||||||
Message: parent.Message,
|
|
||||||
Author: parent.Committer.Name,
|
|
||||||
Hash: parent.Hash.String(),
|
|
||||||
}
|
|
||||||
commits = append(commits, commit)
|
|
||||||
log.Tracef("Found parent check for merge commits for hash %s", c.ParentHashes[1].String())
|
|
||||||
|
|
||||||
commits = append(commits, g.getParents(parent)...)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return commits, errors.Wrap(err, "Could not read commits, check git clone depth in your ci")
|
return nil, errors.Wrap(err, "Could not read commits, check git clone depth in your ci")
|
||||||
}
|
}
|
||||||
|
|
||||||
return commits, nil
|
l := make([]shared.Commit, 0)
|
||||||
|
|
||||||
|
for _, value := range commits {
|
||||||
|
l = append(l, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GitUtil) getParents(current *object.Commit) []shared.Commit {
|
return l, nil
|
||||||
commits := make([]shared.Commit, 0)
|
|
||||||
for _, i2 := range current.ParentHashes {
|
|
||||||
parent, err := g.Repository.CommitObject(i2)
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
commit := shared.Commit{
|
|
||||||
Message: parent.Message,
|
|
||||||
Author: parent.Committer.Name,
|
|
||||||
Hash: parent.Hash.String(),
|
|
||||||
}
|
|
||||||
commits = append(commits, commit)
|
|
||||||
if len(parent.ParentHashes) == 1 {
|
|
||||||
commits = append(commits, g.getParents(parent)...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return commits
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user