<commit_before># encoding: UTF-8
require "test_helper"

class BranchTest < Rugged::TestCase
  include Rugged::TempRepositoryAccess

  def test_list_all_names
    assert_equal [
      "master",
      "origin/HEAD",
      "origin/master",
      "origin/packed",
    ], @repo.branches.each_name.sort
  end

  def test_list_only_local_branches
    assert_equal ["master"], @repo.branches.each_name(:local).sort
  end

  def test_list_only_remote_branches
    assert_equal [
      "origin/HEAD",
      "origin/master",
      "origin/packed",
    ], @repo.branches.each_name(:remote).sort
  end

  def test_get_latest_commit_in_branch
    tip = @repo.branches["master"].tip
<commit_msg>Add tests that show how ambiguous branch lookup works.<commit_after># encoding: UTF-8
require "test_helper"

class BranchTest < Rugged::TestCase
  include Rugged::TempRepositoryAccess

  def test_list_all_names
    assert_equal [
      "master",
      "origin/HEAD",
      "origin/master",
      "origin/packed",
    ], @repo.branches.each_name.sort
  end

  def test_lookup_with_ambiguous_names
    @repo.branches.create("origin/master", "41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9")

    assert_equal "41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9", @repo.branches["origin/master"].target

    assert_equal "41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9", @repo.branches["heads/origin/master"].target
    assert_equal "36060c58702ed4c2a40832c51758d5344201d89a", @repo.branches["remotes/origin/master"].target

    assert_equal "41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9", @repo.branches["refs/heads/origin/master"].target
    assert_equal "36060c58702ed4c2a40832c51758d5344201d89a", @repo.branches["refs/remotes/origin/master"].target
  end

  def test_list_only_local_branches
    assert_equal ["master"], @repo.branches.each_name(:local).sort
  end

  def test_list_only_remote_branches
    assert_equal [
      "origin/HEAD",
      "origin/master",
      "origin/packed",
    ], @repo.branches.each_name(:remote).sort
  end

  def test_get_latest_commit_in_branch
    tip = @repo.branches["master"].tip

{'fraction_non_alphanumeric': 0.10939759036144578, 'fraction_numerical': 0.07325301204819278, 'mean_word_length': 4.43455497382199, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4781794', 'n_tokens_mistral': 822, 'n_tokens_neox': 738, 'n_words': 102}