示例#1
0
 def test_only_title(self):
     self.assertEqual(("foobar", "something\nawesome"),
                      gpr.parse_pr_message("foobar\nsomething\nawesome"))
     self.assertEqual(("foobar", "something\nawesome\n"),
                      gpr.parse_pr_message("foobar\nsomething\nawesome\n"))
     self.assertEqual(
         ("foobar", "something\nawesome\n"),
         gpr.parse_pr_message("foobar\n\nsomething\nawesome\n"))
 def test_only_title(self):
     self.useFixture(fixtures.EnvironmentVariable("EDITOR", "cat"))
     tempdir = self.useFixture(fixtures.TempDir()).path
     os.chdir(tempdir)
     self.assertEqual(("foobar", "something\nawesome"),
                      gpr.parse_pr_message("foobar\nsomething\nawesome"))
     self.assertEqual(("foobar", "something\nawesome\n"),
                      gpr.parse_pr_message("foobar\nsomething\nawesome\n"))
     self.assertEqual(
         ("foobar", "something\nawesome\n"),
         gpr.parse_pr_message("foobar\n\nsomething\nawesome\n"))
示例#3
0
    def test_git_get_title_and_message(self):
        gpr._run_shell_command(["git", "init", "--quiet"])
        gpr._run_shell_command(["git", "remote", "add", "origin",
                                "https://github.com/jd/git-pull-request.git"])
        gpr._run_shell_command(["git", "config", "branch.master.merge",
                                "refs/heads/master"])
        gpr._run_shell_command(["git", "config", "branch.master.remote",
                                "origin"])
        gpr._run_shell_command(["git", "config", "user.name", "nobody"])
        gpr._run_shell_command(["git", "config", "user.email",
                                "*****@*****.**"])
        gpr._run_shell_command(["git", "commit", "--allow-empty",
                                "--no-edit", "-q",
                                "-m", "Import"])
        gpr._run_shell_command(["git", "commit", "--allow-empty",
                                "--no-edit", "-q",
                                "-m", "First message"])
        gpr._run_shell_command(["git", "commit", "--allow-empty",
                                "--no-edit", "-q",
                                "-m", "Last message\n\nLong body, "
                                "but not so long\n"])

        with open(os.path.join(
                  self.tempdir,
                  "PULL_REQUEST_TEMPLATE.md"), "w+") as pr_template:
            pr_template.write("# test")

        self.assertEqual(
            (1,
             "Last message",
             "# test\n"
             "> ------------------------ >8 ------------------------\n"
             "> Do not modify or remove the line above.\n"
             "> Everything below it will be ignored.\n"
             "## Last message\n\n"
             "Long body, but not so long"),
            gpr.git_get_title_and_message("master^", "master"))
        self.assertEqual(
            (2,
             "Pull request for master",
             "# test\n"
             "> ------------------------ >8 ------------------------\n"
             "> Do not modify or remove the line above.\n"
             "> Everything below it will be ignored.\n"
             "## First message\n\n\n"
             "## Last message\n\n"
             "Long body, but not so long"),
            gpr.git_get_title_and_message("master^^", "master"))

        count, title, message = gpr.git_get_title_and_message(
            "master^^", "master",
        )

        assert gpr.parse_pr_message(message) == ("# test", "")