Skip to content

Commit

Permalink
Rename Rugged::Branch.find to Rugged::Branch.lookup.
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurschreiber committed Aug 7, 2012
1 parent 8e50440 commit 8839c7d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/rugged/branch.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
module Rugged module Rugged
class Branch class Branch
def self.find(repo, name) def self.lookup(repo, name)
if name == "HEAD" || name.match(%r{^(refs/heads/|refs/remotes/)}) if name == "HEAD" || name.match(%r{^(refs/heads/|refs/remotes/)})
ref = repo.ref(name) ref = repo.ref(name)
else else
Expand Down
4 changes: 2 additions & 2 deletions lib/rugged/repository.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def remotes
end end


def branches def branches
Rugged::Branch.each(self).map { |name| Rugged::Branch.find(self, name) } Rugged::Branch.each(self).map { |name| Rugged::Branch.lookup(self, name) }
end end


def create_branch(name, sha_or_ref = "HEAD") def create_branch(name, sha_or_ref = "HEAD")
Expand All @@ -138,7 +138,7 @@ def create_branch(name, sha_or_ref = "HEAD")
end end


Branch.create(self, name, target) Branch.create(self, name, target)
Branch.find(self, name) Branch.lookup(self, name)
end end


# Get the content of a file at a specific revision. # Get the content of a file at a specific revision.
Expand Down
12 changes: 6 additions & 6 deletions test/branch_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
end end
end end


context "Rugged::Branch.find" do context "Rugged::Branch.lookup" do
setup do setup do
@path = temp_repo("testrepo.git") @path = temp_repo("testrepo.git")
@repo = Rugged::Repository.new(@path) @repo = Rugged::Repository.new(@path)
end end


test "can look up local branches" do test "can look up local branches" do
branch = Rugged::Branch.find(@repo, "master") branch = Rugged::Branch.lookup(@repo, "master")
refute_nil branch refute_nil branch


assert_equal "master", branch.name assert_equal "master", branch.name
Expand All @@ -45,7 +45,7 @@
end end


test "can look up a local branch by its canonical name" do test "can look up a local branch by its canonical name" do
branch = Rugged::Branch.find(@repo, "refs/heads/master") branch = Rugged::Branch.lookup(@repo, "refs/heads/master")
refute_nil branch refute_nil branch


assert_equal "master", branch.name assert_equal "master", branch.name
Expand All @@ -54,7 +54,7 @@
end end


test "can look up remote branches" do test "can look up remote branches" do
branch = Rugged::Branch.find(@repo, "origin/packed") branch = Rugged::Branch.lookup(@repo, "origin/packed")
refute_nil branch refute_nil branch


assert_equal "origin/packed", branch.name assert_equal "origin/packed", branch.name
Expand All @@ -63,7 +63,7 @@
end end


test "can look up a local branch by its canonical name" do test "can look up a local branch by its canonical name" do
branch = Rugged::Branch.find(@repo, "refs/remotes/origin/packed") branch = Rugged::Branch.lookup(@repo, "refs/remotes/origin/packed")
refute_nil branch refute_nil branch


assert_equal "origin/packed", branch.name assert_equal "origin/packed", branch.name
Expand All @@ -75,7 +75,7 @@
new_branch = @repo.create_branch("Ångström", "5b5b025afb0b4c913b4c338a42934a3863bf3644") new_branch = @repo.create_branch("Ångström", "5b5b025afb0b4c913b4c338a42934a3863bf3644")
refute_nil new_branch refute_nil new_branch


retrieved_branch = Rugged::Branch.find(@repo, "Ångström") retrieved_branch = Rugged::Branch.lookup(@repo, "Ångström")
refute_nil retrieved_branch refute_nil retrieved_branch


assert_equal new_branch, retrieved_branch assert_equal new_branch, retrieved_branch
Expand Down

0 comments on commit 8839c7d

Please sign in to comment.