// Path: src/main/java/de/bbe_consulting/mavento/type/DiffPatch.java
// public class DiffPatch {
// 
//     private String targetDirectory;
//     private String targetFileName = "";
//     private String patchFileName;
//     private List<String> diffContent;
//     private String statsLine = "";
//     
//     public DiffPatch(String fileName, String targetDir, List<String> patch) {
//         targetDirectory = targetDir;
//         patchFileName = fileName;
//         diffContent = patch;
//     }
// 
//     public String getTargetDirectory() {
//         return targetDirectory;
//     }
// 
//     public void setTargetDirectory(String targetDirectory) {
//         this.targetDirectory = targetDirectory;
//     }
// 
//     public String getPatchFileName() {
//         return patchFileName;
//     }
// 
//     public void setPatchFileName(String patchFileName) {
//         this.patchFileName = patchFileName;
//     }
// 
//     public List<String> getDiffContent() {
//         return diffContent;
//     }
// 
//     public void setDiffContent(List<String> diffContent) {
//         this.diffContent = diffContent;
//     }
// 
//     public String getTargetFileName() {
//         if (targetFileName.isEmpty()) {
//             targetFileName = Paths.get(targetDirectory).resolve(Paths.get(patchFileName)).toString();
//         }
//         return targetFileName;
//     }
// 
//     public String getStatsLine() {
//         if (statsLine.isEmpty()) {
//             final Iterator<String> patchContent = diffContent.iterator();
//             String currentLine = "";
//             int addCount = 0;
//             int delCount = 0;
//             int blockCount = 0;
//             while (patchContent.hasNext()) {
//                 currentLine = patchContent.next();
//                 if (currentLine.startsWith("@@")) {
//                     ++blockCount;
//                 } else if (currentLine.startsWith("- ")) {
//                     ++delCount;
//                 } else if (currentLine.startsWith("+ ")) {
//                     ++addCount;
//                 }
//             }
//             statsLine = "[@" + blockCount + "/+" + addCount + "/-" + delCount + "]";
//         }
//         return statsLine;
//     }
//     
// }


import java.io.IOException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import de.bbe_consulting.mavento.type.DiffPatch;
import difflib.DiffUtils;
import difflib.Patch;
import difflib.PatchFailedException;
                    r.add(new DiffPatch(currentPatchFile, targetDir, currentPatchContent));
                }
                currentPatchFile = DiffUtil.getFileName(currentLine);
                currentPatchContent = new LinkedList<String>();
            } else if (currentLine.startsWith("--- ")) {
                // handle header for single patch files
                if (!isIndexed) {
                    // new patch, put previous patch content into result map if possible
                    if (currentPatchFile != "" && currentPatchContent != null) {
                        r.add(new DiffPatch(currentPatchFile, targetDir, currentPatchContent));
                    }
                    currentPatchFile = currentLine;
                    currentPatchContent = new LinkedList<String>();
                }
                // add line to current patch content
                if (currentPatchContent != null) {
                    currentPatchContent.add(currentLine);
                }
            } else {
                // just add line to current patch content
                if (currentPatchContent != null) {
                    currentPatchContent.add(currentLine);
                }
            }
            
        }
        // add the last patch
        if (currentPatchFile != null && currentPatchContent != null) {
            r.add(new DiffPatch(currentPatchFile, targetDir, currentPatchContent));
        }
// Path: src/main/java/de/bbe_consulting/mavento/type/DiffPatch.java
// public class DiffPatch {
// 
//     private String targetDirectory;
//     private String targetFileName = "";
//     private String patchFileName;
//     private List<String> diffContent;
//     private String statsLine = "";
//     
//     public DiffPatch(String fileName, String targetDir, List<String> patch) {
//         targetDirectory = targetDir;
//         patchFileName = fileName;
//         diffContent = patch;
//     }
// 
//     public String getTargetDirectory() {
//         return targetDirectory;
//     }
// 
//     public void setTargetDirectory(String targetDirectory) {
//         this.targetDirectory = targetDirectory;
//     }
// 
//     public String getPatchFileName() {
//         return patchFileName;
//     }
// 
//     public void setPatchFileName(String patchFileName) {
//         this.patchFileName = patchFileName;
//     }
// 
//     public List<String> getDiffContent() {
//         return diffContent;
//     }
// 
//     public void setDiffContent(List<String> diffContent) {
//         this.diffContent = diffContent;
//     }
// 
//     public String getTargetFileName() {
//         if (targetFileName.isEmpty()) {
//             targetFileName = Paths.get(targetDirectory).resolve(Paths.get(patchFileName)).toString();
//         }
//         return targetFileName;
//     }
// 
//     public String getStatsLine() {
//         if (statsLine.isEmpty()) {
//             final Iterator<String> patchContent = diffContent.iterator();
//             String currentLine = "";
//             int addCount = 0;
//             int delCount = 0;
//             int blockCount = 0;
//             while (patchContent.hasNext()) {
//                 currentLine = patchContent.next();
//                 if (currentLine.startsWith("@@")) {
//                     ++blockCount;
//                 } else if (currentLine.startsWith("- ")) {
//                     ++delCount;
//                 } else if (currentLine.startsWith("+ ")) {
//                     ++addCount;
//                 }
//             }
//             statsLine = "[@" + blockCount + "/+" + addCount + "/-" + delCount + "]";
//         }
//         return statsLine;
//     }
//     
// }


// Path: src/main/java/de/bbe_consulting/mavento/helper/DiffUtil.java
import java.io.IOException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import de.bbe_consulting.mavento.type.DiffPatch;
import difflib.DiffUtils;
import difflib.Patch;
import difflib.PatchFailedException;

                    r.add(new DiffPatch(currentPatchFile, targetDir, currentPatchContent));
                }
                currentPatchFile = DiffUtil.getFileName(currentLine);
                currentPatchContent = new LinkedList<String>();
            } else if (currentLine.startsWith("--- ")) {
                // handle header for single patch files
                if (!isIndexed) {
                    // new patch, put previous patch content into result map if possible
                    if (currentPatchFile != "" && currentPatchContent != null) {
                        r.add(new DiffPatch(currentPatchFile, targetDir, currentPatchContent));
                    }
                    currentPatchFile = currentLine;
                    currentPatchContent = new LinkedList<String>();
                }
                // add line to current patch content
                if (currentPatchContent != null) {
                    currentPatchContent.add(currentLine);
                }
            } else {
                // just add line to current patch content
                if (currentPatchContent != null) {
                    currentPatchContent.add(currentLine);
                }
            }
            
        }
        // add the last patch
        if (currentPatchFile != null && currentPatchContent != null) {
            r.add(new DiffPatch(currentPatchFile, targetDir, currentPatchContent));
        }
        return r;