chyle icon indicating copy to clipboard operation
chyle copied to clipboard

i cannot generate changelog for one commit repo

Open opensovereigncloud-user opened this issue 8 months ago • 2 comments

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?

opensovereigncloud-user avatar Mar 27 '25 08:03 opensovereigncloud-user

@antham what do you think about this suggestion?

lukas016 avatar Apr 07 '25 12:04 lukas016

Hi, sorry I left this in a corner, I will check that this week.

antham avatar Apr 07 '25 13:04 antham