Skip to content

i cannot generate changelog for one commit repo #169

@opensovereigncloud-user

Description

Hi,

i have small problem with your implementation. It isn't possible generate changelog for repositories with one commit or i cannot generate all commits from beginning of log history because i need one starting commit which isn't part of changelog.

Problem is in your FetchCommits logic.

I did small test with git.Log function which works nice for me but maybe some edge cases can exist which i don't know.

	rep, err := git.PlainOpen(".")
	commiter, err := rep.Log(&git.LogOptions{
		From:  plumbing.NewHash("3dd34d71af8f1039adffdb620023ae59f5f27cec"), // toCommit
		Order: git.LogOrderCommitterTime,
	})
	if err != nil {
		fmt.Println(err)
		return
	}

	arr := []*object.Commit{}
	commiter.ForEach(func(obj *object.Commit) error {
		if obj.Hash.String() != "bd9026774cb0f2e6eca27fa9a3e7327b15f8ddad" { // fromCommit
			arr = append(arr, obj)
		} else {
			return storer.ErrStop
		}
		return nil
	})

This solution has benefit that fromCommit can be empty string and in this case it will generate commits from beginning of log history.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions