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 tree_at similar to blob_at #453

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/rugged/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,17 @@ def fetch(remote_or_url, *args)
remote_or_url.fetch(*args)
end

# Get the tree at a path for a specific revision.
#
# revision - The String SHA1.
# path - The String file path.
#
# Returns a String.
def tree_at(revision, path)
tree = Rugged::Commit.lookup(self, revision).tree
tree.path(path)[:oid]
Copy link
Member

Choose a reason for hiding this comment

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

The way this is implemented right now, #tree_at would return the tree's oid, not the actual Rugged::Tree object. This is different from how #blob_at works.

Would you mind fixing this up and adding some test cases?

end

# Push a list of refspecs to the given remote.
#
# refspecs - A list of refspecs that should be pushed to the remote.
Expand Down