Skip to content

Commit 189f149

Browse files
committed
#651 Added setting to add custom prefix to generated history files
1 parent c1cacbf commit 189f149

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

src/Readme.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ For further details take a look at LICENSE.txt.
6767

6868
CHANGELOG
6969

70+
5.2.2.0
71+
72+
* New: #651 Added setting to add custom prefix to generated history files
73+
7074
5.2.1.0
7175

7276
* New: Added 'Crap Score' metric for Coberatura coverage files (contrbuted by @rikrak)

src/ReportGenerator.Core/Generator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ public void GenerateReport(
328328

329329
if (historyStorage != null)
330330
{
331-
new HistoryReportGenerator(historyStorage)
331+
new HistoryReportGenerator(historyStorage, settings.HistoryFileNamePrefix)
332332
.CreateReport(parserResult.Assemblies, executionTime, reportConfiguration.Tag);
333333
}
334334

src/ReportGenerator.Core/Reporting/History/HistoryReportGenerator.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,20 @@ internal class HistoryReportGenerator
2828
/// </summary>
2929
private readonly IHistoryStorage historyStorage;
3030

31+
/// <summary>
32+
/// Optional custom file prefix.
33+
/// </summary>
34+
private readonly string customfilePrefix;
35+
3136
/// <summary>
3237
/// Initializes a new instance of the <see cref="HistoryReportGenerator" /> class.
3338
/// </summary>
3439
/// <param name="historyStorage">The history storage.</param>
35-
internal HistoryReportGenerator(IHistoryStorage historyStorage)
40+
/// <param name="customfilePrefix">Optional custom file prefix.</param>
41+
internal HistoryReportGenerator(IHistoryStorage historyStorage, string customfilePrefix)
3642
{
3743
this.historyStorage = historyStorage ?? throw new ArgumentNullException(nameof(historyStorage));
44+
this.customfilePrefix = string.IsNullOrWhiteSpace(customfilePrefix) ? string.Empty : "_" + customfilePrefix;
3845
}
3946

4047
/// <summary>
@@ -86,7 +93,7 @@ internal void CreateReport(IEnumerable<Assembly> assemblies, DateTime executionT
8693
}
8794

8895
var document = new XDocument(new XDeclaration("1.0", "UTF-8", "yes"), rootElement);
89-
string fileName = date + "_CoverageHistory.xml";
96+
string fileName = date + this.customfilePrefix + "_CoverageHistory.xml";
9097
try
9198
{
9299
using (var stream = new MemoryStream())

src/ReportGenerator.Core/Settings.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,10 @@ public int CachingDuringOfRemoteFilesInMinutes
7575
/// Gets or sets the maximum decimal places for coverage quotas / percentages.
7676
/// </summary>
7777
public int MaximumDecimalPlacesForCoverageQuotas { get; set; } = 1;
78+
79+
/// <summary>
80+
/// Gets or sets the prefix for history files.
81+
/// </summary>
82+
public string HistoryFileNamePrefix { get; set; }
7883
}
7984
}

src/ReportGenerator.Core/appsettings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
"excludeTestProjects": false,
1919
"createSubdirectoryForAllReportTypes": false,
2020
"customHeadersForRemoteFiles": null,
21-
"defaultAssemblyName": "Default"
21+
"defaultAssemblyName": "Default",
22+
"maximumDecimalPlacesForCoverageQuotas": 1,
23+
"historyFileNamePrefix": null
2224
}
2325
}

0 commit comments

Comments
 (0)