lib/gitlab_git/repository.rb in gitlab_git-10.3.2 vs lib/gitlab_git/repository.rb in gitlab_git-10.4.0
- old
+ new
@@ -59,17 +59,23 @@
# Returns an Array of Branches
def branches
rugged.branches.map do |rugged_ref|
begin
- Branch.new(rugged_ref.name, rugged_ref.target)
+ Branch.new(self, rugged_ref.name, rugged_ref.target)
rescue Rugged::ReferenceError
# Omit invalid branch
end
end.compact.sort_by(&:name)
end
+ def local_branches
+ rugged.branches.each(:local).map do |branch|
+ Branch.new(self, branch.name, branch.target)
+ end
+ end
+
# Returns the number of valid branches
def branch_count
rugged.branches.count do |ref|
begin
ref.name && ref.target # ensures the branch is valid
@@ -97,11 +103,11 @@
if tag_message.respond_to?(:chomp)
message = tag_message.chomp
end
end
- Tag.new(ref.name, ref.target, message)
+ Tag.new(self, ref.name, ref.target, message)
end.sort_by(&:name)
end
# Returns true if the given tag exists
#
@@ -130,11 +136,11 @@
end
# Deprecated. Will be removed in 5.2
def heads
rugged.references.each("refs/heads/*").map do |head|
- Gitlab::Git::Ref.new(head.name, head.target)
+ Gitlab::Git::Ref.new(self, head.name, head.target)
end.sort_by(&:name)
end
def has_commits?
!empty?
@@ -335,12 +341,11 @@
# Return the object that +revspec+ points to. If +revspec+ is an
# annotated tag, then return the tag's target instead.
def rev_parse_target(revspec)
obj = rugged.rev_parse(revspec)
- obj = obj.target while obj.is_a?(Rugged::Tag::Annotation)
- obj
+ Ref.dereference_object(obj)
end
# Return a collection of Rugged::Commits between the two revspec arguments.
# See http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for
# a detailed list of valid arguments.
@@ -743,10 +748,10 @@
# Examples:
# create_branch("feature")
# create_branch("other-feature", "master")
def create_branch(ref, start_point = "HEAD")
rugged_ref = rugged.branches.create(ref, start_point)
- Branch.new(rugged_ref.name, rugged_ref.target)
+ Branch.new(self, rugged_ref.name, rugged_ref.target)
rescue Rugged::ReferenceError => e
raise InvalidRef.new("Branch #{ref} already exists") if e.to_s =~ /'refs\/heads\/#{ref}'/
raise InvalidRef.new("Invalid reference #{start_point}")
end