@@ -29,8 +29,9 @@ public class VersionOracle
29
29
/// <param name="projectDirectory"></param>
30
30
/// <param name="gitRepoDirectory"></param>
31
31
/// <param name="cloudBuild"></param>
32
+ /// <param name="overrideBuildNumberOffset"></param>
32
33
/// <returns></returns>
33
- public static VersionOracle Create ( string projectDirectory , string gitRepoDirectory = null , ICloudBuild cloudBuild = null )
34
+ public static VersionOracle Create ( string projectDirectory , string gitRepoDirectory = null , ICloudBuild cloudBuild = null , int ? overrideBuildNumberOffset = null )
34
35
{
35
36
Requires . NotNull ( projectDirectory , nameof ( projectDirectory ) ) ;
36
37
if ( string . IsNullOrEmpty ( gitRepoDirectory ) )
@@ -40,14 +41,14 @@ public static VersionOracle Create(string projectDirectory, string gitRepoDirect
40
41
41
42
using ( var git = OpenGitRepo ( gitRepoDirectory ) )
42
43
{
43
- return new VersionOracle ( projectDirectory , git , cloudBuild ) ;
44
+ return new VersionOracle ( projectDirectory , git , cloudBuild , overrideBuildNumberOffset ) ;
44
45
}
45
46
}
46
47
47
48
/// <summary>
48
49
/// Initializes a new instance of the <see cref="VersionOracle"/> class.
49
50
/// </summary>
50
- public VersionOracle ( string projectDirectory , LibGit2Sharp . Repository repo , ICloudBuild cloudBuild )
51
+ public VersionOracle ( string projectDirectory , LibGit2Sharp . Repository repo , ICloudBuild cloudBuild , int ? overrideBuildNumberOffset = null )
51
52
{
52
53
var repoRoot = repo ? . Info ? . WorkingDirectory ? . TrimEnd ( Path . DirectorySeparatorChar , Path . AltDirectorySeparatorChar ) ;
53
54
var relativeRepoProjectDirectory = ! string . IsNullOrWhiteSpace ( repoRoot )
@@ -60,6 +61,19 @@ public VersionOracle(string projectDirectory, LibGit2Sharp.Repository repo, IClo
60
61
61
62
var workingVersion = VersionFile . GetVersion ( projectDirectory ) ;
62
63
64
+ if ( overrideBuildNumberOffset . HasValue )
65
+ {
66
+ if ( committedVersion != null )
67
+ {
68
+ committedVersion . BuildNumberOffset = overrideBuildNumberOffset . Value ;
69
+ }
70
+
71
+ if ( workingVersion != null )
72
+ {
73
+ workingVersion . BuildNumberOffset = overrideBuildNumberOffset . Value ;
74
+ }
75
+ }
76
+
63
77
this . VersionOptions = committedVersion ?? workingVersion ;
64
78
65
79
this . GitCommitId = commit ? . Id . Sha ?? cloudBuild ? . GitCommitId ?? null ;
0 commit comments