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

Add Repository.Log() method (fix #298) #337

Merged
merged 2 commits into from
Apr 11, 2017
Merged

Add Repository.Log() method (fix #298) #337

merged 2 commits into from
Apr 11, 2017

Conversation

ajnavarro
Copy link
Contributor

@ajnavarro ajnavarro commented Apr 10, 2017

  • CommitIter is now an interface
  • The old CommitIter implementation is now called StorerCommitIter
  • CommitWalker and CommitWalkerPost are now iterators (CommitPreIterator and CommitPostIterator).
  • Remove Commit.History() method. There are so many ways to iterate a commit history, depending of the use case. Now, instead of use the History() method, you must use CommitPreIterator or CommitPostIterator.
  • Move commitSorterer to references.go because is the only place that it is used, and it must not be used into another place.
  • Make References method private, it must only be used into blame logic.
  • Added a TODO into references method, where the sortCommits is used to remove it in a near future.

@ajnavarro ajnavarro requested review from smola and alcortesm April 10, 2017 14:53
@codecov
Copy link

codecov bot commented Apr 10, 2017

Codecov Report

Merging #337 into master will decrease coverage by 0.02%.
The diff coverage is 82.53%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #337      +/-   ##
=========================================
- Coverage   77.32%   77.3%   -0.03%     
=========================================
  Files         117     117              
  Lines        8030    8062      +32     
=========================================
+ Hits         6209    6232      +23     
- Misses       1160    1164       +4     
- Partials      661     666       +5
Impacted Files Coverage Δ
options.go 87.09% <ø> (ø) ⬆️
references.go 73.22% <100%> (+2.04%) ⬆️
blame.go 54.23% <100%> (ø) ⬆️
plumbing/object/commit.go 71.3% <100%> (-1.63%) ⬇️
plumbing/revlist/revlist.go 80.59% <77.77%> (+0.29%) ⬆️
plumbing/object/commit_walker.go 78.37% <78.78%> (-8.86%) ⬇️
repository.go 72.14% <81.25%> (+0.36%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3daede5...efef147. Read the comment docs.

}

// StorerCommitIter provides an iterator from commits in an EncodedObjectStorer.
type StorerCommitIter struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this object can be private, since we are using through the interface

// storer.EncodedObjectIter and returns a *CommitIter that iterates over all
// commits contained in the storer.EncodedObjectIter.
//
// Any non-commit object returned by the storer.EncodedObjectIter is skipped.
func NewCommitIter(s storer.EncodedObjectStorer, iter storer.EncodedObjectIter) *CommitIter {
return &CommitIter{iter, s}
func NewStorerCommitIter(s storer.EncodedObjectStorer, iter storer.EncodedObjectIter) CommitIter {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the implementation is private the method can be calle NewCommitIter

@@ -271,6 +265,10 @@ func (iter *CommitIter) ForEach(cb func(*Commit) error) error {
})
}

func (iter *StorerCommitIter) Close() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not tested

@@ -292,9 +290,3 @@ func SortCommits(l []*Commit) {
s := &commitSorterer{l}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not tested

options.go Outdated

// LogOptions describes how a log action should be performed.
type LogOptions struct {
// From is the hash of the commit from we want to start the log history.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative wording:
When the From option is set the log will only contain commits reachable from it. If this option is not set, HEAD will be used as the default From.

- CommitIter is now an interface
- The old CommitIter implementation is now called StorerCommitIter
- CommitWalker and CommitWalkerPost are now iterators (CommitPreIterator and CommitPostIterator).
- Remove Commit.History() method. There are so many ways to iterate a commit history, depending of the use case. Now, instead of use the History() method, you must use CommitPreIterator or CommitPostIterator.
- Move commitSorterer to references.go because is the only place that it is used, and it must not be used into another place.
- Make References method private, it must only be used into blame logic.
- Added a TODO into references method, where the sortCommits is used to remove it in a near future.
@mcuadros mcuadros merged commit 9b45f46 into src-d:master Apr 11, 2017
@ajnavarro ajnavarro deleted the repository-log branch April 12, 2017 07:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants