You've already forked go-semantic-release
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
|
||||
}
|
||||
|
||||
var commits []shared.Commit
|
||||
commits := make(map[string]shared.Commit)
|
||||
var foundEnd bool
|
||||
|
||||
err = cIter.ForEach(func(c *object.Commit) error {
|
||||
@@ -147,55 +147,25 @@ func (g *GitUtil) GetCommits(lastTagHash string) ([]shared.Commit, error) {
|
||||
|
||||
if !foundEnd {
|
||||
log.Tracef("Found commit with hash %s", c.Hash.String())
|
||||
commit := shared.Commit{
|
||||
commits[c.Hash.String()] = shared.Commit{
|
||||
Message: c.Message,
|
||||
Author: c.Committer.Name,
|
||||
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
|
||||
})
|
||||
|
||||
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 {
|
||||
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
|
||||
return l, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user