Ejemplo n.º 1
0
    def test_generate_authors(self):
        author_old = "Foo Foo <*****@*****.**>"
        author_new = "Bar Bar <*****@*****.**>"
        co_author = "Foo Bar <*****@*****.**>"
        co_author_by = "Co-authored-by: " + co_author

        git_log_cmd = ("git --git-dir=%s log --format" % self.git_dir)
        git_co_log_cmd = ("git log --git-dir=%s" % self.git_dir)
        cmd_map = {
            git_log_cmd: author_new,
            git_co_log_cmd: co_author_by,
        }

        exist_files = [self.git_dir,
                       os.path.join(self.temp_path, "AUTHORS.in")]
        self.useFixture(fixtures.MonkeyPatch(
            "os.path.exists",
            lambda path: os.path.abspath(path) in exist_files))

        self.useFixture(fixtures.FakePopen(lambda proc_args: {
            "stdout": six.BytesIO(
                self._fake_log_output(proc_args["args"][2], cmd_map))
        }))

        with open(os.path.join(self.temp_path, "AUTHORS.in"), "w") as auth_fh:
            auth_fh.write("%s\n" % author_old)

        packaging.generate_authors(git_dir=self.git_dir,
                                   dest_dir=self.temp_path)

        with open(os.path.join(self.temp_path, "AUTHORS"), "r") as auth_fh:
            authors = auth_fh.read()
            self.assertTrue(author_old in authors)
            self.assertTrue(author_new in authors)
            self.assertTrue(co_author in authors)
Ejemplo n.º 2
0
    def test_generate_authors(self):
        author_old = u"Foo Foo <*****@*****.**>"
        author_new = u"Bar Bar <*****@*****.**>"
        co_author = u"Foo Bar <*****@*****.**>"
        co_author_by = u"Co-authored-by: " + co_author

        git_log_cmd = "git --git-dir=%s log --format=%%aN <%%aE>" % self.git_dir
        git_co_log_cmd = "git --git-dir=%s log" % self.git_dir
        git_top_level = "git rev-parse --show-toplevel"
        cmd_map = {git_log_cmd: author_new, git_co_log_cmd: co_author_by, git_top_level: self.root_dir}

        exist_files = [self.git_dir, os.path.join(self.temp_path, "AUTHORS.in")]
        self.useFixture(fixtures.MonkeyPatch("os.path.exists", lambda path: os.path.abspath(path) in exist_files))

        def _fake_run_shell_command(cmd, **kwargs):
            return cmd_map[" ".join(cmd)]

        self.useFixture(fixtures.MonkeyPatch("pbr.packaging._run_shell_command", _fake_run_shell_command))

        with open(os.path.join(self.temp_path, "AUTHORS.in"), "w") as auth_fh:
            auth_fh.write("%s\n" % author_old)

        packaging.generate_authors(git_dir=self.git_dir, dest_dir=self.temp_path)

        with open(os.path.join(self.temp_path, "AUTHORS"), "r") as auth_fh:
            authors = auth_fh.read()
            self.assertTrue(author_old in authors)
            self.assertTrue(author_new in authors)
            self.assertTrue(co_author in authors)
Ejemplo n.º 3
0
    def test_generate_authors(self):
        author_old = u"Foo Foo <*****@*****.**>"
        author_new = u"Bar Bar <*****@*****.**>"
        co_author = u"Foo Bar <*****@*****.**>"
        co_author_by = u"Co-authored-by: " + co_author

        git_log_cmd = ("git --git-dir=%s log --format=%%aN <%%aE>" %
                       self.git_dir)
        git_co_log_cmd = ("git --git-dir=%s log" % self.git_dir)
        git_top_level = "git rev-parse --show-toplevel"
        cmd_map = {
            git_log_cmd: author_new,
            git_co_log_cmd: co_author_by,
            git_top_level: self.root_dir,
        }

        exist_files = [
            self.git_dir,
            os.path.join(self.temp_path, "AUTHORS.in")
        ]
        self.useFixture(
            fixtures.MonkeyPatch(
                "os.path.exists",
                lambda path: os.path.abspath(path) in exist_files))

        def _fake_run_shell_command(cmd, **kwargs):
            return cmd_map[" ".join(cmd)]

        self.useFixture(
            fixtures.MonkeyPatch("pbr.packaging._run_shell_command",
                                 _fake_run_shell_command))

        with open(os.path.join(self.temp_path, "AUTHORS.in"), "w") as auth_fh:
            auth_fh.write("%s\n" % author_old)

        packaging.generate_authors(git_dir=self.git_dir,
                                   dest_dir=self.temp_path)

        with open(os.path.join(self.temp_path, "AUTHORS"), "r") as auth_fh:
            authors = auth_fh.read()
            self.assertTrue(author_old in authors)
            self.assertTrue(author_new in authors)
            self.assertTrue(co_author in authors)
Ejemplo n.º 4
0
    def test_generate_authors(self):
        author_old = "Foo Foo <*****@*****.**>"
        author_new = "Bar Bar <*****@*****.**>"
        co_author = "Foo Bar <*****@*****.**>"
        co_author_by = "Co-authored-by: " + co_author

        git_log_cmd = ("git --git-dir=%s log --format" % self.git_dir)
        git_co_log_cmd = ("git log --git-dir=%s" % self.git_dir)
        git_top_level = "git rev-parse --show-toplevel"
        cmd_map = {
            git_log_cmd: author_new,
            git_co_log_cmd: co_author_by,
            git_top_level: self.root_dir,
        }

        exist_files = [
            self.git_dir,
            os.path.join(self.temp_path, "AUTHORS.in")
        ]
        self.useFixture(
            fixtures.MonkeyPatch(
                "os.path.exists",
                lambda path: os.path.abspath(path) in exist_files))

        self.useFixture(
            fixtures.FakePopen(
                lambda proc_args: {
                    "stdout":
                    BytesIO(
                        self._fake_log_output(proc_args["args"][2], cmd_map))
                }))

        with open(os.path.join(self.temp_path, "AUTHORS.in"), "w") as auth_fh:
            auth_fh.write("%s\n" % author_old)

        packaging.generate_authors(git_dir=self.git_dir,
                                   dest_dir=self.temp_path)

        with open(os.path.join(self.temp_path, "AUTHORS"), "r") as auth_fh:
            authors = auth_fh.read()
            self.assertTrue(author_old in authors)
            self.assertTrue(author_new in authors)
            self.assertTrue(co_author in authors)