File tree 5 files changed +14
-10
lines changed
5 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -87,9 +87,7 @@ private string ResolveCurrentBranch()
87
87
private void CleanupDuplicateOrigin ( )
88
88
{
89
89
var remoteToKeep = DefaultRemoteName ;
90
-
91
- var isDynamicRepo = ! string . IsNullOrWhiteSpace ( options . Value . DynamicGitRepositoryPath ) ;
92
- using var repo = new Repository ( isDynamicRepo ? options . Value . DotGitDirectory : options . Value . ProjectRootDirectory ) ;
90
+ using var repo = new Repository ( options . Value . GitRootPath ) ;
93
91
94
92
// check that we have a remote that matches defaultRemoteName if not take the first remote
95
93
if ( ! repo . Network . Remotes . Any ( remote => remote . Name . Equals ( DefaultRemoteName , StringComparison . InvariantCultureIgnoreCase ) ) )
Original file line number Diff line number Diff line change @@ -11,11 +11,7 @@ public class GitRepository : IGitRepository
11
11
private IRepository repositoryInstance => repositoryLazy . Value ;
12
12
13
13
public GitRepository ( IOptions < GitVersionOptions > options )
14
- : this ( ( ) =>
15
- {
16
- var isDynamicRepo = ! string . IsNullOrWhiteSpace ( options . Value . DynamicGitRepositoryPath ) ;
17
- return isDynamicRepo ? options . Value . DotGitDirectory : options . Value . ProjectRootDirectory ;
18
- } )
14
+ : this ( ( ) => options . Value . GitRootPath )
19
15
{
20
16
}
21
17
Original file line number Diff line number Diff line change @@ -38,6 +38,14 @@ public static string GetProjectRootDirectory(this GitVersionOptions gitVersionOp
38
38
return repository . Info . WorkingDirectory ;
39
39
}
40
40
41
+ public static string GetGitRootPath ( this GitVersionOptions options )
42
+ {
43
+ var isDynamicRepo = ! string . IsNullOrWhiteSpace ( options . DynamicGitRepositoryPath ) ;
44
+ var rootDirectory = isDynamicRepo ? options . DotGitDirectory : options . ProjectRootDirectory ;
45
+
46
+ return rootDirectory ;
47
+ }
48
+
41
49
public static string GetDynamicGitRepositoryPath ( this GitVersionOptions gitVersionOptions )
42
50
{
43
51
if ( string . IsNullOrWhiteSpace ( gitVersionOptions . RepositoryInfo . TargetUrl ) ) return null ;
Original file line number Diff line number Diff line change @@ -11,19 +11,22 @@ public class GitVersionOptions
11
11
private Lazy < string > dotGitDirectory ;
12
12
private Lazy < string > projectRootDirectory ;
13
13
private Lazy < string > dynamicGitRepositoryPath ;
14
+ private Lazy < string > gitRootPath ;
14
15
15
16
public GitVersionOptions ( )
16
17
{
17
18
dotGitDirectory = new Lazy < string > ( this . GetDotGitDirectory ) ;
18
19
projectRootDirectory = new Lazy < string > ( this . GetProjectRootDirectory ) ;
19
20
dynamicGitRepositoryPath = new Lazy < string > ( this . GetDynamicGitRepositoryPath ) ;
21
+ gitRootPath = new Lazy < string > ( this . GetGitRootPath ) ;
20
22
}
21
23
22
24
public string WorkingDirectory { get ; set ; }
23
25
24
26
public string DotGitDirectory => dotGitDirectory . Value ;
25
27
public string ProjectRootDirectory => projectRootDirectory . Value ;
26
28
public string DynamicGitRepositoryPath => dynamicGitRepositoryPath . Value ;
29
+ public string GitRootPath => gitRootPath . Value ;
27
30
28
31
public AssemblyInfoData AssemblyInfo { get ; } = new AssemblyInfoData ( ) ;
29
32
public AuthenticationInfo Authentication { get ; } = new AuthenticationInfo ( ) ;
Original file line number Diff line number Diff line change @@ -141,8 +141,7 @@ private List<string> CalculateDirectoryContents(string root)
141
141
142
142
private string GetRepositorySnapshotHash ( )
143
143
{
144
- var isDynamicRepo = ! string . IsNullOrWhiteSpace ( options . Value . DynamicGitRepositoryPath ) ;
145
- using var repo = new Repository ( isDynamicRepo ? options . Value . DotGitDirectory : options . Value . ProjectRootDirectory ) ;
144
+ using var repo = new Repository ( options . Value . GitRootPath ) ;
146
145
147
146
var head = repo . Head ;
148
147
if ( head . Tip == null )
You can’t perform that action at this time.
0 commit comments