Exemplo n.º 1
0
    def testSimpleFork(self):
        self._createCommitNewFile("README")
        self.repo("branch", "fork")
        self._createCommitNewFile("ONLY_MASTER")
        self.repo("checkout", "fork")
        self._createCommitNewFile("ONLY_FORK", "ONLY_FORK", "BODY\nBODY")
        self._createCommitNewFile("ONLY_FORK2")

        log = phlgit_log.get_range_to_here_raw_body(self.repo, "master")
        self.assertIn("ONLY_FORK", log)
        self.assertNotIn("ONLY_MASTER", log)
        self.assertNotIn("README", log)

        hashes = phlgit_log.get_range_to_here_hashes(self.repo, "master")
        hashes2 = phlgit_log.get_range_hashes(self.repo, "master", "fork")
        self.assertListEqual(hashes, hashes2)
        r0 = phlgit_log.make_revision_from_hash(self.repo, hashes[0])
        self.assertEqual(r0.subject, "ONLY_FORK")
        self.assertEqual(r0.message, "BODY\nBODY\n")
        r1 = phlgit_log.make_revision_from_hash(self.repo, hashes[1])
        self.assertEqual(r1.subject, "ONLY_FORK2")
        self.assertIsNotNone(r1.message)
        self.assertIsInstance(r1.message, str)

        committers = phlgit_log.get_author_names_emails_from_hashes(
            self.repo, hashes)
        self.assertEqual(len(committers), 1)
        self.assertEqual(committers[0], (self.authorName, self.authorEmail))
Exemplo n.º 2
0
    def get_author_names_emails(self):
        """Return a list of (name, email) tuples from the branch."""
        hashes = self._get_commit_hashes()

        # names and emails are only mentioned once, in the order that they
        # appear.  reverse the order so that the the most recent commit is
        # considered first.
        hashes.reverse()
        names_emails = phlgit_log.get_author_names_emails_from_hashes(
            self._repo, hashes)
        names_emails.reverse()

        return names_emails
Exemplo n.º 3
0
    def get_author_names_emails(self):
        """Return a list of (name, email) tuples from the branch."""
        hashes = self._get_commit_hashes()

        # names and emails are only mentioned once, in the order that they
        # appear.  reverse the order so that the the most recent commit is
        # considered first.
        hashes.reverse()
        names_emails = phlgit_log.get_author_names_emails_from_hashes(
            self._repo, hashes)
        names_emails.reverse()

        return names_emails
def getPrimaryNameEmailAndUserFromBranch(clone, conduit, base, branch):
    hashes = phlgit_log.get_range_hashes(clone, base, branch)
    if not hashes:
        raise abdt_exception.AbdUserException("no history to diff")
    commit = hashes[-1]
    committer = phlgit_log.get_author_names_emails_from_hashes(
        clone, [commit])[0]
    name = committer[0]
    email = committer[1]
    user = phlcon_user.query_users_from_emails(conduit, [email])[0]
    if not user:
        raise abdt_exception.AbdUserException(
            "first committer is not a Phabricator user")
    return name, email, user
def getAnyUserFromBranch(clone, conduit, base, branch):
    if phlgitu_ref.parse_ref_hash(clone, base) is None:
        hashes = phlgit_log.get_last_n_commit_hashes_from_ref(clone, 1, branch)
    else:
        hashes = phlgit_log.get_range_hashes(clone, base, branch)

    if not hashes:
        hashes = phlgit_log.get_last_n_commit_hashes_from_ref(clone, 1, branch)
    committers = phlgit_log.get_author_names_emails_from_hashes(clone, hashes)
    emails = [committer[1] for committer in committers]
    users = phlcon_user.query_users_from_emails(conduit, emails)
    for user in users:
        if user:
            return user
    raise abdt_exception.NoUsersOnBranchException(branch, base, emails)
    def get_any_author_emails(self):
        """Return a list of emails from the branch.

        If the branch has an invalid base or has no history against the base
        then resort to using the whole history.

        Useful if 'get_author_names_emails' fails.

        """
        if phlgit_revparse.get_sha1_or_none(self._clone, self._review_branch.remote_base) is None:
            hashes = phlgit_log.get_last_n_commit_hashes_from_ref(self._clone, 1, self._review_branch.remote_branch)
        else:
            hashes = self._get_commit_hashes()
        if not hashes:
            hashes = phlgit_log.get_last_n_commit_hashes_from_ref(self._clone, 1, self._review_branch.remote_branch)
        committers = phlgit_log.get_author_names_emails_from_hashes(self._clone, hashes)
        emails = [committer[1] for committer in committers]
        return emails
    def test_simpleWorkflow(self):
        self._devCheckoutPushNewBranch("ph-review/simpleWorkflow/master")
        self._devPushNewFile("NEWFILE")
        self._phabUpdateWithExpectations(total=1, bad=0)
        self._devPushNewFile("NEWFILE2")
        self._phabUpdateWithExpectations(total=1, bad=0)
        self._acceptTheOnlyReview()
        self._phabUpdateWithExpectations(total=0, bad=0, emails=0)

        # check the author on master
        with phlsys_fs.chdir_context("developer"):
            runCommands("git fetch -p", "git checkout master")
            clone = phlsys_git.GitClone(".")
            head = phlgit_log.get_last_commit_hash(clone)
            authors = phlgit_log.get_author_names_emails_from_hashes(
                clone, [head])
            author = authors[0]
            name = author[0]
            email = author[1]
            self.assertEqual(self.author_account.user, name)
            self.assertEqual(self.author_account.email, email)
Exemplo n.º 8
0
    def get_any_author_emails(self):
        """Return a list of emails from the branch.

        If the branch has an invalid base or has no history against the base
        then resort to using the whole history.

        Useful if 'get_author_names_emails' fails.

        """
        if phlgit_revparse.get_sha1_or_none(
                self._repo, self._review_branch.remote_base) is None:
            hashes = phlgit_log.get_last_n_commit_hashes_from_ref(
                self._repo, 1, self._review_branch.remote_branch)
        else:
            hashes = self._get_commit_hashes()
        if not hashes:
            hashes = phlgit_log.get_last_n_commit_hashes_from_ref(
                self._repo, 1, self._review_branch.remote_branch)
        committers = phlgit_log.get_author_names_emails_from_hashes(
            self._repo, hashes)
        emails = [committer[1] for committer in committers]
        return emails
Exemplo n.º 9
0
 def get_author_names_emails(self):
     """Return a list of (name, email) tuples from the branch."""
     hashes = self._get_commit_hashes()
     return phlgit_log.get_author_names_emails_from_hashes(
         self._clone, hashes)