Skip to content

Commit

Permalink
LRDOCS-6295 Listing renamed files is not necessary; if header ID stay…
Browse files Browse the repository at this point in the history
…s the same, the file name can change and KB only recognizes it as modified file
  • Loading branch information
codyhoag committed Aug 2, 2019
1 parent 87b1b37 commit efe3ec5
Showing 1 changed file with 20 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ private static List<String> getModifiedFiles(String commit, String docLocation,

List<String> modifiedFiles = new ArrayList<String> ();
List<String> deletedFiles = new ArrayList<String> ();
HashMap<String, String> renamedFiles = new HashMap<String, String> ();
//HashMap<String, String> renamedFiles = new HashMap<String, String> ();

for (DiffEntry entry : entries) {

Expand All @@ -425,13 +425,13 @@ private static List<String> getModifiedFiles(String commit, String docLocation,
entryPath = entryPath.replace("/images-dxp/", "/images/");
}

if (entry.getChangeType().toString().equals("RENAME")) {
renamedFiles.put(entry.getOldPath(), entryPath);
modifiedFiles.add(entryPath);
}
else {
modifiedFiles.add(entryPath);
}
//if (entry.getChangeType().toString().equals("RENAME")) {
// renamedFiles.put(entry.getOldPath(), entryPath);
// modifiedFiles.add(entryPath);
//}
//else {
modifiedFiles.add(entryPath);
//}
}
else if (entry.getOldPath().startsWith(docLocation) &&
entry.getChangeType().toString().equals("DELETE")) {
Expand All @@ -444,8 +444,8 @@ else if (entry.getOldPath().startsWith(docLocation) &&
System.exit(0);
}

if (!deletedFiles.isEmpty() || !renamedFiles.isEmpty()) {
writeDeletedTextFile(deletedFiles, renamedFiles, distDir);
if (!deletedFiles.isEmpty()) {
writeDeletedTextFile(deletedFiles, distDir);
}

repo.close();
Expand Down Expand Up @@ -645,19 +645,17 @@ private static void unzipFile(String docDir, String zipName)
}

/**
* Writes deleted and renamed files to a {@code .txt} file. This is useful
* to notify the publisher of the files that must be manually deleted from
* the Knowledge Base portlet, since the import of a Zip only adds files or
* modifies existing files, but cannot delete them.
* Writes deleted files to a {@code .txt} file. This is useful to notify the
* publisher of the files that must be manually deleted from the Knowledge
* Base portlet, since the import of a Zip only adds files or modifies
* existing files, but cannot delete them.
*
* @param deletedFiles the files that were deleted in the Git repo since
* the last publication
* @param renamedFiles the files that were renamed in the Git repo since
* the last publication
* @param distDir the folder where the Zip is generated (e.g., {@code dist})
* @throws IOException if an IO exception occurred
*/
private static void writeDeletedTextFile(List<String> deletedFiles, HashMap<String, String> renamedFiles, String distDir)
private static void writeDeletedTextFile(List<String> deletedFiles, String distDir)
throws IOException {

PrintWriter writer = new PrintWriter(distDir + "/delete-files.txt", "UTF-8");
Expand All @@ -667,12 +665,12 @@ private static void writeDeletedTextFile(List<String> deletedFiles, HashMap<Stri
writer.println(file);
}

writer.println("");
writer.println("\nRENAMED:\n");
//writer.println("");
//writer.println("\nRENAMED:\n");

for (Map.Entry<String, String> entry : renamedFiles.entrySet()) {
writer.println("Old article to delete: " + entry.getKey() + " (renamed/moved to: " + entry.getValue() + ")");
}
//for (Map.Entry<String, String> entry : renamedFiles.entrySet()) {
// writer.println("Old article to delete: " + entry.getKey() + " (renamed/moved to: " + entry.getValue() + ")");
//}

writer.close();
}
Expand Down

0 comments on commit efe3ec5

Please sign in to comment.