예제 #1
0
    def test_fixup_patch(self):
        expected = """\
From ply Mon Sep 17 00:00:00 2001
From: Rick Harris <*****@*****.**>
Date: Mon, 17 Jun 2013 11:35:48 -0500
Subject: Bar


diff --git a/README b/README
index bc56c4d..ebd7525 100644
--- a/README
+++ b/README
@@ -1 +1 @@
-Foo
+Bar
-- 
1.8.3

"""
        actual = fixup_patch.fixup_patch(self.ORIGINAL)
        self.assertLongMatch(expected, actual)
예제 #2
0
    def _create_patches(self, since):
        """
        The default output of format-patch isn't ideally suited for our
        purposes since it contains extraneous info as well as text that
        changes even if the underlying patch doesn't change.

        The following options are used to correct this:

        --keep-subject - remove unecessary [PATCH] prefix
        --no-stat - remove unecessary diffstat
        --no-numbered - remove number of patches in set from subject line

        In addition, we need to rewrite the first-line of the patch-file to
        remove an unecessary commit-hash. On refresh, this would change even
        if the actual patch was the same, leading to very noisy diffs.
        """
        filenames = self.format_patch(
            since, keep_subject=True, no_numbered=True, no_stat=True)

        source_paths = []
        for filename in filenames:
            from_path = os.path.join(self.path, filename)
            with tempfile.NamedTemporaryFile(delete=False) as to_file:
                with open(from_path) as from_file:
                    original = from_file.read()
                    fixed = fixup_patch.fixup_patch(original)
                    to_file.write(fixed)

            # Strip 0001- prefix that git-format-patch uses
            source_path = os.path.join(self.path, filename.split('-', 1)[1])
            shutil.move(to_file.name, source_path)
            os.unlink(from_path)

            source_paths.append(source_path)

        parent_patch_name = self._get_commit_hash_and_patch_name(
            since)[1]

        return source_paths, parent_patch_name
예제 #3
0
파일: __init__.py 프로젝트: sorrowless/ply
    def _create_patches(self, since):
        """
        The default output of format-patch isn't ideally suited for our
        purposes since it contains extraneous info as well as text that
        changes even if the underlying patch doesn't change.

        The following options are used to correct this:

        --keep-subject - remove unecessary [PATCH] prefix
        --no-stat - remove unecessary diffstat
        --no-numbered - remove number of patches in set from subject line

        In addition, we need to rewrite the first-line of the patch-file to
        remove an unecessary commit-hash. On refresh, this would change even
        if the actual patch was the same, leading to very noisy diffs.
        """
        filenames = self.format_patch(
            since, keep_subject=True, no_numbered=True, no_stat=True)

        source_paths = []
        for filename in filenames:
            from_path = os.path.join(self.path, filename)
            with tempfile.NamedTemporaryFile(delete=False) as to_file:
                with open(from_path) as from_file:
                    original = from_file.read()
                    fixed = fixup_patch.fixup_patch(original)
                    to_file.write(fixed)

            # Strip 0001- prefix that git-format-patch uses
            source_path = os.path.join(self.path, filename.split('-', 1)[1])
            shutil.move(to_file.name, source_path)
            os.unlink(from_path)

            source_paths.append(source_path)

        parent_patch_name = self._get_commit_hash_and_patch_name(
            since)[1]

        return source_paths, parent_patch_name