49
49
/**
50
50
* Helper class to generate diff reports after patching
51
51
*/
52
- public class DiffUtils {
52
+ public final class DiffUtils {
53
53
54
- public static Logger LOG = LoggerFactory .getLogger (DiffUtils .class );
54
+ public static final Logger LOG = LoggerFactory .getLogger (DiffUtils .class );
55
+ private static final DateFormat DATE = new SimpleDateFormat ("yyyy-MM-dd HH:mm" );
55
56
56
57
private static String reportHeader ;
57
58
private static String reportFooter ;
58
59
private static String fileHeader1 ;
59
60
private static String fileHeader2 ;
60
61
private static String fileFooter ;
61
62
62
- private static DateFormat DATE = new SimpleDateFormat ("yyyy-MM-dd HH:mm" );
63
-
64
63
static {
65
64
try {
66
65
reportHeader = IOUtils .toString (DiffUtils .class .getResourceAsStream ("/patch-report-header.html" ), "UTF-8" );
@@ -74,6 +73,9 @@ public class DiffUtils {
74
73
}
75
74
}
76
75
76
+ private DiffUtils () {
77
+ }
78
+
77
79
/**
78
80
* <p>Having four commits, generate single, HTML report about all modified files</p>
79
81
* <p>Please excuse inline html code.</p>
@@ -139,35 +141,35 @@ public static void generateDiffReport(Patch patch, PatchResult patchResult, Git
139
141
result .write (reportHeader .replace ("@PATCH_ID@" , pd .getId ()));
140
142
PatchReport pr = patchResult .getReport ();
141
143
142
- result .write ("<table class=\" summary\" >\n " +
143
- " <tr>\n " +
144
- " <td class=\" f\" >Patch ID:</td><td>" + pr .getId () + "</td>\n " +
145
- " </tr>\n " +
146
- " <tr>\n " +
147
- " <td class=\" f\" >Patch type:</td><td>" + (pr .isRollup () ? "rollup" : "non-rollup" ) + "</td>\n " +
148
- " </tr>\n " +
149
- " <tr>\n " +
150
- " <td class=\" f\" >Installation date:</td><td>" + DATE .format (pr .getTimestamp ()) + "</td>\n " +
151
- " </tr>\n " +
152
- " <tr>\n " +
153
- " <td class=\" f\" >Bundles updated</td><td>" + pr .getUpdatedBundles () + "</td>\n " +
154
- " </tr>\n " +
155
- " <tr>\n " +
156
- " <td class=\" f\" >Features updated</td><td>" + pr .getUpdatedFeatures () + "</td>\n " +
157
- " </tr>\n " +
158
- " <tr>\n " +
159
- " <td class=\" f\" >Features overriden</td><td>" + pr .getOverridenFeatures () + "</td>\n " +
160
- " </tr>\n " +
161
- " <tr>\n " +
162
- " <td class=\" f\" >File conflicts</td><td>" + conflicts .size () + "</td>\n " +
163
- " </tr>\n " +
164
- " </table>\n " +
165
- "</div>\n " );
144
+ result .write ("<table class=\" summary\" >\n "
145
+ + " <tr>\n "
146
+ + " <td class=\" f\" >Patch ID:</td><td>" + pr .getId () + "</td>\n "
147
+ + " </tr>\n "
148
+ + " <tr>\n "
149
+ + " <td class=\" f\" >Patch type:</td><td>" + (pr .isRollup () ? "rollup" : "non-rollup" ) + "</td>\n "
150
+ + " </tr>\n "
151
+ + " <tr>\n "
152
+ + " <td class=\" f\" >Installation date:</td><td>" + DATE .format (pr .getTimestamp ()) + "</td>\n "
153
+ + " </tr>\n "
154
+ + " <tr>\n "
155
+ + " <td class=\" f\" >Bundles updated</td><td>" + pr .getUpdatedBundles () + "</td>\n "
156
+ + " </tr>\n "
157
+ + " <tr>\n "
158
+ + " <td class=\" f\" >Features updated</td><td>" + pr .getUpdatedFeatures () + "</td>\n "
159
+ + " </tr>\n "
160
+ + " <tr>\n "
161
+ + " <td class=\" f\" >Features overriden</td><td>" + pr .getOverridenFeatures () + "</td>\n "
162
+ + " </tr>\n "
163
+ + " <tr>\n "
164
+ + " <td class=\" f\" >File conflicts</td><td>" + conflicts .size () + "</td>\n "
165
+ + " </tr>\n "
166
+ + " </table>\n "
167
+ + "</div>\n " );
166
168
167
169
if (conflicts .size () > 0 ) {
168
- result .write ("<h1 class=\" header\" >\n " +
169
- " <div>Conflicting files</div>\n " +
170
- "</h1>\n " );
170
+ result .write ("<h1 class=\" header\" >\n "
171
+ + " <div>Conflicting files</div>\n "
172
+ + "</h1>\n " );
171
173
}
172
174
173
175
for (Map .Entry <String , DiffEntry []> e : report .entrySet ()) {
@@ -180,40 +182,40 @@ public static void generateDiffReport(Patch patch, PatchResult patchResult, Git
180
182
result .write (e .getKey ());
181
183
result .write (fileHeader2 );
182
184
// we have max 3 entries (not all entries may be present
183
- result .write ("<td class=\" side\" >\n " +
184
- " <div class=\" header\" >Custom version</div>\n " +
185
- " <div class=\" content" + (e .getValue ()[0 ] != null ? "" : " empty" ) + "\" >" );
185
+ result .write ("<td class=\" side\" >\n "
186
+ + " <div class=\" header\" >Custom version</div>\n "
187
+ + " <div class=\" content" + (e .getValue ()[0 ] != null ? "" : " empty" ) + "\" >" );
186
188
if (e .getValue ()[0 ] != null ) {
187
189
// custom change
188
190
diff (git , reader , e .getValue ()[0 ], result );
189
191
} else {
190
192
result .write ("No change" );
191
193
}
192
- result .write ("</div>\n " +
193
- " </td>" );
194
- result .write ("<td class=\" side\" >\n " +
195
- " <div class=\" header\" >Patch</div>\n " +
196
- " <div class=\" content" + (e .getValue ()[1 ] != null ? "" : " empty" ) + "\" >" );
194
+ result .write ("</div>\n "
195
+ + " </td>" );
196
+ result .write ("<td class=\" side\" >\n "
197
+ + " <div class=\" header\" >Patch</div>\n "
198
+ + " <div class=\" content" + (e .getValue ()[1 ] != null ? "" : " empty" ) + "\" >" );
197
199
if (e .getValue ()[1 ] != null ) {
198
200
// patch change
199
201
diff (git , reader , e .getValue ()[1 ], result );
200
202
} else {
201
203
result .write ("No change" );
202
204
}
203
- result .write ("</div>\n " +
204
- " </td>" );
205
- result .write ("<td class=\" side\" >\n " +
206
- " <div class=\" header\" >Final version</div>\n " +
207
- " <div class=\" content" + (e .getValue ()[2 ] != null ? "" : " empty" ) + "\" >" );
205
+ result .write ("</div>\n "
206
+ + " </td>" );
207
+ result .write ("<td class=\" side\" >\n "
208
+ + " <div class=\" header\" >Final version</div>\n "
209
+ + " <div class=\" content" + (e .getValue ()[2 ] != null ? "" : " empty" ) + "\" >" );
208
210
if (e .getValue ()[2 ] != null ) {
209
211
// effective change - should always be available
210
212
// or maybe not when both patch and user removed the file?
211
213
diff (git , reader , e .getValue ()[2 ], result );
212
214
} else {
213
215
result .write ("No change" );
214
216
}
215
- result .write ("</div>\n " +
216
- " </td>" );
217
+ result .write ("</div>\n "
218
+ + " </td>" );
217
219
result .write (fileFooter );
218
220
}
219
221
0 commit comments