Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

v2.0.0: CommitIter panics when Close is called #4

@toqueteos

Description

@toqueteos

If we add the following test to repository_test.go we can see this in action:

func (s *SuiteRepository) TestCommitIterClosePanic(c *C) {
    r, err := NewRepository(RepositoryFixture)
    r.Remotes["origin"].upSrv = &MockGitUploadPackService{}

    c.Assert(err, IsNil)
    c.Assert(r.Pull("origin", "refs/heads/master"), IsNil)

    commits := r.Commits()
    commits.Close()
}

This is due to https://github.com/src-d/go-git/blob/v2.0.0/repository.go#L98, it seems commit iteration needs a small rework.

Possible solutions

  • Make iter.Add and iter.Close private. Consecuences: We can't stop iterators anymore unless they reach the end.
  • Rework how iterators work all over the repo.
  • Add a check on Close to avoid more than once calls to it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions