(self)
Format the diff into files and extract the patch for each one of them.

        Example :
            diff --git a/test.txt b/test.txt\n
            new file mode 100644\n
            index 0000000..b80e3df\n
            --- /dev/null\n
            +++ b/test\n
            @@ -0,0 +1,28 @@\n
            +this is a test patch\n
Format the diff into files and extract the patch for each one of them.
Format the diff into files and extract the patch for each one of them .
def get_files(self) -> Iterable[CommitFile]:
        """
        Format the diff into files and extract the patch for each one of them.

        Example :
            diff --git a/test.txt b/test.txt\n
            new file mode 100644\n
            index 0000000..b80e3df\n
            --- /dev/null\n
            +++ b/test\n
            @@ -0,0 +1,28 @@\n
            +this is a test patch\n
        """
        list_diff = re.split(r"^diff --git ", self.patch, flags=re.MULTILINE)[1:]

        for diff in list_diff:
            lines = diff.split("\n")

            filename = self.get_filename(lines[0])
            if is_filepath_excluded(filename, self.exclusion_regexes):
                continue

            filemode = self.get_filemode(lines[1])
            document = "\n".join(lines[filemode.start :])
            file_size = len(document.encode("utf-8"))
            if file_size > MAX_FILE_SIZE * 0.90:
                continue

            if document:
                yield CommitFile(document, filename, filemode, file_size)
def get_files ( self ) -> Iterable [ CommitFile ] : list_diff = re . split ( r"^diff --git " , self . patch , flags = re . MULTILINE ) [ 1 : ] for diff in list_diff : lines = diff . split ( "\n" ) filename = self . get_filename ( lines [ 0 ] ) if is_filepath_excluded ( filename , self . exclusion_regexes ) : continue filemode = self . get_filemode ( lines [ 1 ] ) document = "\n" . join ( lines [ filemode . start : ] ) file_size = len ( document . encode ( "utf-8" ) ) if file_size > MAX_FILE_SIZE * 0.90 : continue if document : yield CommitFile ( document , filename , filemode , file_size )