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

Add docs for GitRevWalker and push_head! #22654

Merged
merged 4 commits into from
Aug 25, 2017
Merged

Add docs for GitRevWalker and push_head! #22654

merged 4 commits into from
Aug 25, 2017

Conversation

kshyatt
Copy link
Contributor

@kshyatt kshyatt commented Jul 1, 2017

No description provided.

@kshyatt kshyatt added docs This change adds or pertains to documentation libgit2 The libgit2 library or the LibGit2 stdlib module labels Jul 1, 2017
@kshyatt kshyatt requested a review from ararslan July 1, 2017 21:24
# Examples
```julia
oids = LibGit2.with(LibGit2.GitRevWalker(repo)) do walker
LibGit2.map((oid,repo)->string(oid), walker, by = LibGit2.Consts.SORT_TIME)
Copy link
Member

Choose a reason for hiding this comment

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

You didn't use spaces around the = in by in the example below this one. It would be good to make them consistent, and in this case IMO it looks nicer without the spaces as it is in the second example.


A `GitRevWalker` *walks* through the *revisions* (i.e. commits) of
a git repository `repo`. It is a collection of the commits
in the repository, and supports iteration and calls to [`map`](@ref)
Copy link
Contributor

Choose a reason for hiding this comment

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

but LibGit.map is distinct from Base.map and has its own kwargs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can add a docstring for LibGit2.map, for some reason (???) I thought we already had one.


```julia
cnt = LibGit2.with(LibGit2.GitRevWalker(repo)) do walker
count((oid,repo)->(oid == commit_oid1), walker, oid=commit_oid1, by=LibGit2.Consts.SORT_TIME)
Copy link
Contributor

Choose a reason for hiding this comment

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

are oid and by keyword args specific to LibGit2.count then or ... ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Guess this should get its own docstring too.

Copy link
Contributor

Choose a reason for hiding this comment

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

and be module-qualified I guess if the example is intended to be runnable from outside the LibGit2 module (I hope LibGit2.count isn't extending Base.count with libgit2-specific kwargs?)

"""
GitRevWalker(repo::GitRepo)

A `GitRevWalker` *walks* through the *revisions* (i.e. commits) of
Copy link
Member

Choose a reason for hiding this comment

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

Maybe something like

A GitRevWalker is an iterable collection of the revisions (i.e. commits) of a git repository repo. Iteration over the collection walks the individual commits and returns (oid, repo) tuples, where oid is a [GitHash](@ ref) and repo is the given repository.

Like many other such collections, GitRevWalker supports [map](@ ref) and [count](@ ref). The latter could, for example, be used to determine the number of commits in a repository made by a particular author.

Also TIL that LibGit2.map is a thing. Do we have a docstring that points to that specifically?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope! I can add one for this file

@@ -83,6 +82,27 @@ end

repository(w::GitRevWalker) = w.owner

"""
LibGit2.map(f::Function, walker::GitRevWalker; oid::GitHash=GitHash(), by::Cint = Consts.SORT_NONE, rev::Bool=false)
Copy link
Member

Choose a reason for hiding this comment

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

Inconsistent spacing around =. In this case I'd remove the spaces between Cint and Consts.

@@ -112,6 +132,30 @@ function Base.map(f::Function, walker::GitRevWalker;
return res
end

"""
LibGit2.count(f::Function, walker::GitRevWalker; oid::GitHash=GitHash(), by::Cint = Consts.SORT_NONE, rev::Bool=false)
Copy link
Member

Choose a reason for hiding this comment

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

Same comment regarding spacing

LibGit2.push!(w::GitRevWalker, cid::GitHash)

Start the [`GitRevWalker`](@ref) `walker` at commit `cid`. This function can be used
to apply a function to all commits since in a certain year, by passing the first commit
Copy link
Contributor

Choose a reason for hiding this comment

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

since or in? both seems redundant

@kshyatt
Copy link
Contributor Author

kshyatt commented Jul 2, 2017

Any ideas on how to fix the broken docs build? It's upset about the duplicate docstrings.

@tkelman
Copy link
Contributor

tkelman commented Jul 2, 2017

add type constraints to some of them?

@kshyatt
Copy link
Contributor Author

kshyatt commented Jul 31, 2017

I can try to fix this tonight but if someone else wants to try go ahead :)

Copy link
Member

@ararslan ararslan left a comment

Choose a reason for hiding this comment

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

GitRevWalker Texas Ranger

@kshyatt
Copy link
Contributor Author

kshyatt commented Aug 24, 2017

Whoever merges this, please remember to squash.

@kshyatt kshyatt merged commit 706e720 into master Aug 25, 2017
@kshyatt kshyatt deleted the ksh/docrevwalk branch August 25, 2017 15:19
giordano added a commit to giordano/julia that referenced this pull request Jan 30, 2021
Reading the documentation is very confusing, because these functions don't
extend the corresponding `Base` functions and they aren't exported.

Ref: JuliaLang#22654 (comment).
KristofferC pushed a commit that referenced this pull request Jan 31, 2021
Reading the documentation is very confusing, because these functions don't
extend the corresponding `Base` functions and they aren't exported.

Ref: #22654 (comment).
ElOceanografo pushed a commit to ElOceanografo/julia that referenced this pull request May 4, 2021
Reading the documentation is very confusing, because these functions don't
extend the corresponding `Base` functions and they aren't exported.

Ref: JuliaLang#22654 (comment).
antoine-levitt pushed a commit to antoine-levitt/julia that referenced this pull request May 9, 2021
Reading the documentation is very confusing, because these functions don't
extend the corresponding `Base` functions and they aren't exported.

Ref: JuliaLang#22654 (comment).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation libgit2 The libgit2 library or the LibGit2 stdlib module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants