def test_invalid_return_code_run_commands(self):
     "Passing incorrect commands returns non zero exit status"
     with phlsys_fs.nostd() as stderr:
         cmd = "time"
         self.assertRaises(
             phlsys_subprocess.CalledProcessError,
             phlsys_subprocess.run_commands,
             cmd)
         self.assertTrue(cmd in stderr.out)
Exemple #2
0
def squash(repo, source, message, author=None):
    # TODO: test merging with no effective changes
    with phlsys_fs.nostd():
        try:
            repo("merge", "--squash", source)
            if author:
                result = repo("commit", "-m", message, "--author", author)
            else:
                result = repo("commit", "-m", message)
        except phlsys_subprocess.CalledProcessError as e:
            raise MergeException(e.stdout)

    return result
def squash(repo, source, message, author=None):
    # TODO: test merging with no effective changes
    with phlsys_fs.nostd():
        try:
            repo("merge", "--squash", source)
            if author:
                result = repo("commit", "-m", message, "--author", author)
            else:
                result = repo("commit", "-m", message)
        except phlsys_subprocess.CalledProcessError as e:
            raise MergeException(e.stdout)

    return result
def land(conduit, wb, gitContext, branch):
    clone = gitContext.clone
    print "landing " + wb.remote_branch + " onto " + wb.remote_base
    name, email, user = abdt_conduitgit.getPrimaryNameEmailAndUserFromBranch(
        clone, conduit, wb.remote_base, wb.remote_branch)
    d = phlcon_differential
    with phlsys_conduit.act_as_user_context(conduit, user):
        phlgit_checkout.new_branch_force_based_on(
            clone, wb.base, wb.remote_base)

        # compose the commit message
        message = d.get_commit_message(conduit, wb.id)

        try:
            with phlsys_fs.nostd():
                squashMessage = phlgit_merge.squash(
                    clone,
                    wb.remote_branch,
                    message,
                    name + " <" + email + ">")
        except phlsys_subprocess.CalledProcessError as e:
            clone.call("reset", "--hard")  # fix the working copy
            raise abdt_exception.LandingException(
                '\n' + e.stdout, branch, wb.base)

        print "- pushing " + wb.remote_base
        phlgit_push.push(clone, wb.base, gitContext.remote)
        print "- deleting " + wb.branch
        phlgit_push.delete(clone, wb.branch, gitContext.remote)
        print "- deleting " + branch
        phlgit_push.delete(clone, branch, gitContext.remote)

    print "- commenting on revision " + str(wb.id)
    commenter = abdcmnt_commenter.Commenter(conduit, wb.id)
    commenter.landedReview(branch, wb.base, squashMessage)

    authorPHID = d.query(conduit, [wb.id])[0].authorPHID
    authorUser = phlcon_user.query_usernames_from_phids(
        conduit, [authorPHID])[0]
    # TODO: there's a potential race condition on the author here
    with phlsys_conduit.act_as_user_context(conduit, authorUser):
        d.close(conduit, wb.id)
 def test_invalid_cmd(self):
     "Passing invalid command - catch OSError"
     with phlsys_fs.nostd() as stderr:
         self.assertRaises(OSError, phlsys_subprocess.run, "invalidcmd")
         self.assertTrue("OSError" in stderr.out)
 def test_invalid_cmd(self):
     "Passing invalid command - catch OSError"
     with phlsys_fs.nostd() as stderr:
         self.assertRaises(OSError, phlsys_subprocess.run, "invalidcmd")
         self.assertTrue("OSError" in stderr.out)