Method: Gitlab::Git::Repository#branches_contains

Defined in:
lib/gitlab_git/repository.rb

#branches_contains(commit) ⇒ Object

Returns branch collection that contains the special commit(SHA1 or name)

Ex.

repo.branch_names_contains('master')


494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
# File 'lib/gitlab_git/repository.rb', line 494

def branches_contains(commit)
  commit_obj = rugged.rev_parse(commit)
  parent = commit_obj.parents.first unless commit_obj.parents.empty?

  walker = Rugged::Walker.new(rugged)

  rugged.branches.select do |branch|
    walker.push(branch.target_id)
    walker.hide(parent) if parent
    result = walker.any? { |c| c.oid == commit_obj.oid }
    walker.reset

    result
  end
end