Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn CommitCollection into a IQueryable<Commit> #148

Closed
nulltoken opened this issue May 14, 2012 · 8 comments
Closed

Turn CommitCollection into a IQueryable<Commit> #148

nulltoken opened this issue May 14, 2012 · 8 comments

Comments

@nulltoken
Copy link
Member

No description provided.

@nufyoot
Copy link

nufyoot commented May 14, 2012

For the IQueryable<Commit> do you have a design pattern we should use? If building around the Commit object then what would be the best way to allow filtering by branch, reference, tag or tag annotation?

@nufyoot
Copy link

nufyoot commented May 14, 2012

To elaborate a little more, would you recommend creating something like this:

LibGit2Sharp.Repository repo;
LibGit2Sharp.Branch branch;

repo.Commits.Where(c => branch.Commits.Contains(c));

@nulltoken
Copy link
Member Author

@nufyoot

If building around the Commit object then what would be the best way to allow filtering by branch, reference, tag or tag annotation?

I may not completely understand your whole question. For instance, I'm not sure to clearly get what would filtering by a tag return.

For the IQueryable do you have a design pattern we should use?

What would be the alternatives?

/cc @davidfowl, @aroben

@nufyoot
Copy link

nufyoot commented May 19, 2012

I'm not sure about alternatives for the IQueryable usage. As for filtering by tag, I merely just read the documentation for the QueryBy function.

@nulltoken
Copy link
Member Author

As for filtering by tag, I merely just read the documentation for the QueryBy function.

OMG... Ok I got it. I clearly misunderstood your remark!

Below my first thoughts:

The QueryBy method defines "boundaries" the revwalk should honor (For instance: start at the commits pointed at by this this branch and this tag and enumerate all their parents until you reach this commit (or until your reach a commit with no parent))

Currently, repo.Commits is a shortcut for repo.Commits.QueryBy( new Filter { Since = repo.Head } );

When I looked at the code repo.Commits.Where(c => branch.Commits.Contains(c)); here's what I understood "Enumerate all the commits that are reachable from both the HEAD and this other branch."

repo.Commits.QueryBy( new Filter { Since = new object[] { repo.Head, branch } } ); would rather mean "Enumerate all the commits that are reachable from either the HEAD or and this other branch.".

@nufyoot
Copy link

nufyoot commented May 19, 2012

Ah, good point. What would be a comfortable syntax do you think? Perhaps add either a method to Commit or an extension method that could be used outside the IQueryable implementation, but is built primarily for IQueryable?

Perhaps something like:

LibGit2Sharp.Repository repo;
LibGit2Sharp.Branch branch1;
LibGit2Sharp.Branch branch2;

repo.Commits.Where(c => c.IsAfter(branch) && c.IsBefore(branch));

Or maybe something like that? I'm up for any suggestions.

@nulltoken
Copy link
Member Author

@nufyoot

What would be a comfortable syntax do you think?

I've thought about this, and I can't come up with something that would be both intuitive and discoverable.

I'm starting to wonder if trying to get rid of QueryBy is achievable, while still making it "easy" for the consumer to process and filter the commits.

The retrieval of the commits through the CommitCollection is already deferred thanks to the CommitEnumerator. Is there another advantage to IQueryable<> that I'm missing?

@nulltoken
Copy link
Member Author

Closing this for now. Feel free to reopen if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants