def testSearchByHash(self):
    commits = self._get_commits()
    hash_of_first_commit = commits[0]

    message = """Revert of some stuff.
    > [turbofan] Sanitize language mode for javascript operators.
    > Reverting """ + hash_of_first_commit + """
    > [email protected]

    Review URL: https://codereview.chromium.org/1084243005

    Cr-Commit-Position: refs/heads/master@{#28088}"""

    self._make_empty_commit(message)

    #Fetch again for an update
    commits = self._get_commits()
    hash_of_first_commit = commits[0]

    result = search_related_commits.search_all_related_commits(
        self.base_dir,
        hash_of_first_commit,
        "HEAD",
        None)

    self._assert_correct_standard_result(result, commits, hash_of_first_commit)
示例#2
0
    def testNothingFound(self):
        commits = self._get_commits()

        self._execute_git(["commit", "--allow-empty", "-m", "A"])
        self._execute_git(["commit", "--allow-empty", "-m", "B"])
        self._execute_git(["commit", "--allow-empty", "-m", "C"])
        self._execute_git(["commit", "--allow-empty", "-m", "D"])

        hash_of_first_commit = commits[0]
        result = search_related_commits.search_all_related_commits(
            self.base_dir, hash_of_first_commit, "HEAD", None)

        self.assertEqual(len(result), 0, "Results found where none should be.")
  def testNothingFound(self):
    commits = self._get_commits()

    self._execute_git(["commit", "--allow-empty", "-m", "A"])
    self._execute_git(["commit", "--allow-empty", "-m", "B"])
    self._execute_git(["commit", "--allow-empty", "-m", "C"])
    self._execute_git(["commit", "--allow-empty", "-m", "D"])

    hash_of_first_commit = commits[0]
    result = search_related_commits.search_all_related_commits(
        self.base_dir,
        hash_of_first_commit,
        "HEAD",
        None)

    self.assertEqual(len(result), 0, "Results found where none should be.")
  def testSearchByCommitPosition(self):
    message = """Revert of some stuff.
    > Cr-Commit-Position: refs/heads/master@{#28059}
    [email protected]

    Review URL: https://codereview.chromium.org/1084243005

    Cr-Commit-Position: refs/heads/master@{#28088}"""

    self._make_empty_commit(message)

    commits = self._get_commits()
    hash_of_first_commit = commits[0]

    result = search_related_commits.search_all_related_commits(
        self.base_dir, hash_of_first_commit, "HEAD", None)

    self._assert_correct_standard_result(result, commits, hash_of_first_commit)
示例#5
0
    def testSearchByCommitPosition(self):
        message = """Revert of some stuff.
    > Cr-Commit-Position: refs/heads/main@{#28059}
    [email protected]

    Review URL: https://codereview.chromium.org/1084243005

    Cr-Commit-Position: refs/heads/main@{#28088}"""

        self._make_empty_commit(message)

        commits = self._get_commits()
        hash_of_first_commit = commits[0]

        result = search_related_commits.search_all_related_commits(
            self.base_dir, hash_of_first_commit, "HEAD", None)

        self._assert_correct_standard_result(result, commits,
                                             hash_of_first_commit)
示例#6
0
    def testSearchByTitle(self):
        message = """Revert of some stuff.
    > [turbofan] Sanitize language mode for javascript operators.
    > Cr-Commit-Position: refs/heads/master@{#289}
    [email protected]

    Review URL: https://codereview.chromium.org/1084243005

    Cr-Commit-Position: refs/heads/master@{#28088}"""

        self._make_empty_commit(message)

        commits = self._get_commits()
        hash_of_first_commit = commits[0]

        result = search_related_commits.search_all_related_commits(
            self.base_dir, hash_of_first_commit, "HEAD", None)

        self._assert_correct_standard_result(result, commits,
                                             hash_of_first_commit)
示例#7
0
    def testConsiderSeparator(self):
        commits = self._get_commits()
        hash_of_first_commit = commits[0]

        # Related commits happen before separator so it is not a hit
        message = """Revert of some stuff: Not a hit
    > [turbofan] Sanitize language mode for javascript operators.
    > Reverting """ + hash_of_first_commit + """
    > [email protected]

    Review URL: https://codereview.chromium.org/1084243005

    Cr-Commit-Position: refs/heads/main@{#28088}"""
        self._make_empty_commit(message)

        # Related commits happen before and after separator so it is a hit
        commit_pos_of_main = "27088"
        message = """Implement awesome feature: Main commit

    Review URL: https://codereview.chromium.org/1084243235

    Cr-Commit-Position: refs/heads/main@{#""" + commit_pos_of_main + "}"
        self._make_empty_commit(message)

        # Separator commit
        message = """Commit which is the origin of the branch

    Review URL: https://codereview.chromium.org/1084243456

    Cr-Commit-Position: refs/heads/main@{#28173}"""
        self._make_empty_commit(message)

        # Filler commit
        message = "Some unrelated commit: Not a hit"
        self._make_empty_commit(message)

        # Related commit after separator: a hit
        message = "Patch r" + commit_pos_of_main + """ done

    Review URL: https://codereview.chromium.org/1084243235

    Cr-Commit-Position: refs/heads/main@{#29567}"""
        self._make_empty_commit(message)

        #Fetch again for an update
        commits = self._get_commits()
        hash_of_first_commit = commits[0]
        hash_of_hit = commits[3]
        hash_of_separator = commits[4]
        hash_of_child_hit = commits[6]

        result = search_related_commits.search_all_related_commits(
            self.base_dir, hash_of_first_commit, "HEAD", hash_of_separator)

        self.assertTrue(result.get(hash_of_hit), "Hit not found")
        self.assertEqual(len(result), 1, "More than one hit found")
        self.assertEqual(len(result.get(hash_of_hit)), 1,
                         "More than one child hit found")
        self.assertEqual(
            result.get(hash_of_hit)[0], hash_of_child_hit,
            "Wrong commit found")
  def testConsiderSeparator(self):
    commits = self._get_commits()
    hash_of_first_commit = commits[0]

    # Related commits happen before separator so it is not a hit
    message = """Revert of some stuff: Not a hit
    > [turbofan] Sanitize language mode for javascript operators.
    > Reverting """ + hash_of_first_commit + """
    > [email protected]

    Review URL: https://codereview.chromium.org/1084243005

    Cr-Commit-Position: refs/heads/master@{#28088}"""
    self._make_empty_commit(message)

    # Related commits happen before and after separator so it is a hit
    commit_pos_of_master = "27088"
    message = """Implement awesome feature: Master commit

    Review URL: https://codereview.chromium.org/1084243235

    Cr-Commit-Position: refs/heads/master@{#""" + commit_pos_of_master + "}"
    self._make_empty_commit(message)

    # Separator commit
    message = """Commit which is the origin of the branch

    Review URL: https://codereview.chromium.org/1084243456

    Cr-Commit-Position: refs/heads/master@{#28173}"""
    self._make_empty_commit(message)

    # Filler commit
    message = "Some unrelated commit: Not a hit"
    self._make_empty_commit(message)

    # Related commit after separator: a hit
    message = "Patch r" + commit_pos_of_master +""" done

    Review URL: https://codereview.chromium.org/1084243235

    Cr-Commit-Position: refs/heads/master@{#29567}"""
    self._make_empty_commit(message)

    #Fetch again for an update
    commits = self._get_commits()
    hash_of_first_commit = commits[0]
    hash_of_hit = commits[3]
    hash_of_separator = commits[4]
    hash_of_child_hit = commits[6]

    result = search_related_commits.search_all_related_commits(
        self.base_dir,
        hash_of_first_commit,
        "HEAD",
        hash_of_separator)

    self.assertTrue(result.get(hash_of_hit), "Hit not found")
    self.assertEqual(len(result), 1, "More than one hit found")
    self.assertEqual(
        len(result.get(hash_of_hit)),
        1,
        "More than one child hit found")
    self.assertEqual(
        result.get(hash_of_hit)[0],
        hash_of_child_hit,
        "Wrong commit found")