@@ -11,34 +11,18 @@ class SpecifiedArgumentRunner
11
11
12
12
public static void Run ( Arguments arguments , IFileSystem fileSystem )
13
13
{
14
- var gitPreparer = new GitPreparer ( arguments ) ;
15
- gitPreparer . InitialiseDynamicRepositoryIfNeeded ( ) ;
16
- var dotGitDirectory = gitPreparer . GetDotGitDirectory ( ) ;
17
- if ( string . IsNullOrEmpty ( dotGitDirectory ) )
18
- {
19
- throw new Exception ( string . Format ( "Failed to prepare or find the .git directory in path '{0}'" , arguments . TargetPath ) ) ;
20
- }
21
- var applicableBuildServers = GetApplicableBuildServers ( arguments . Authentication ) . ToList ( ) ;
22
-
23
- foreach ( var buildServer in applicableBuildServers )
24
- {
25
- buildServer . PerformPreProcessingSteps ( dotGitDirectory , arguments . NoFetch ) ;
26
- }
27
- VersionVariables variables ;
28
- var versionFinder = new GitVersionFinder ( ) ;
29
- var configuration = ConfigurationProvider . Provide ( arguments . TargetPath , fileSystem ) ;
30
-
31
- using ( var repo = RepositoryLoader . GetRepo ( dotGitDirectory ) )
32
- {
33
- var gitVersionContext = new GitVersionContext ( repo , configuration , commitId : arguments . CommitId ) ;
34
- var semanticVersion = versionFinder . FindVersion ( gitVersionContext ) ;
35
- var config = gitVersionContext . Configuration ;
36
- variables = VariableProvider . GetVariablesFor ( semanticVersion , config . AssemblyVersioningScheme , config . VersioningMode , config . ContinuousDeploymentFallbackTag , gitVersionContext . IsCurrentCommitTagged ) ;
37
- }
14
+ var noFetch = arguments . NoFetch ;
15
+ var authentication = arguments . Authentication ;
16
+ var targetPath = arguments . TargetPath ;
17
+ var targetUrl = arguments . TargetUrl ;
18
+ var dynamicRepositoryLocation = arguments . DynamicRepositoryLocation ;
19
+ var targetBranch = arguments . TargetBranch ;
20
+ var commitId = arguments . CommitId ;
21
+ var variables = ExecuteGitVersion ( fileSystem , targetUrl , dynamicRepositoryLocation , authentication , targetBranch , noFetch , targetPath , commitId ) ;
38
22
39
23
if ( arguments . Output == OutputType . BuildServer )
40
24
{
41
- foreach ( var buildServer in applicableBuildServers )
25
+ foreach ( var buildServer in BuildServerList . GetApplicableBuildServers ( authentication ) )
42
26
{
43
27
buildServer . WriteIntegration ( Console . WriteLine , variables ) ;
44
28
}
@@ -63,10 +47,10 @@ public static void Run(Arguments arguments, IFileSystem fileSystem)
63
47
}
64
48
}
65
49
66
- using ( var assemblyInfoUpdate = new AssemblyInfoFileUpdate ( arguments , arguments . TargetPath , variables , fileSystem ) )
50
+ using ( var assemblyInfoUpdate = new AssemblyInfoFileUpdate ( arguments , targetPath , variables , fileSystem ) )
67
51
{
68
- var execRun = RunExecCommandIfNeeded ( arguments , arguments . TargetPath , variables ) ;
69
- var msbuildRun = RunMsBuildIfNeeded ( arguments , arguments . TargetPath , variables ) ;
52
+ var execRun = RunExecCommandIfNeeded ( arguments , targetPath , variables ) ;
53
+ var msbuildRun = RunMsBuildIfNeeded ( arguments , targetPath , variables ) ;
70
54
if ( ! execRun && ! msbuildRun )
71
55
{
72
56
assemblyInfoUpdate . DoNotRestoreAssemblyInfo ( ) ;
@@ -81,9 +65,35 @@ public static void Run(Arguments arguments, IFileSystem fileSystem)
81
65
}
82
66
}
83
67
84
- static IEnumerable < IBuildServer > GetApplicableBuildServers ( Authentication authentication )
68
+ static VersionVariables ExecuteGitVersion ( IFileSystem fileSystem , string targetUrl , string dynamicRepositoryLocation , Authentication authentication , string targetBranch , bool noFetch , string workingDirectory , string commitId )
85
69
{
86
- return BuildServerList . GetApplicableBuildServers ( authentication ) ;
70
+ var gitPreparer = new GitPreparer ( targetUrl , dynamicRepositoryLocation , authentication , targetBranch , noFetch , workingDirectory ) ;
71
+ gitPreparer . InitialiseDynamicRepositoryIfNeeded ( ) ;
72
+ var dotGitDirectory = gitPreparer . GetDotGitDirectory ( ) ;
73
+ var projectRoot = gitPreparer . GetProjectRootDirectory ( ) ;
74
+ if ( string . IsNullOrEmpty ( dotGitDirectory ) || string . IsNullOrEmpty ( projectRoot ) )
75
+ {
76
+ // TODO Link to wiki article
77
+ throw new Exception ( string . Format ( "Failed to prepare or find the .git directory in path '{0}'." , workingDirectory ) ) ;
78
+ }
79
+
80
+ foreach ( var buildServer in BuildServerList . GetApplicableBuildServers ( authentication ) )
81
+ {
82
+ buildServer . PerformPreProcessingSteps ( dotGitDirectory , noFetch ) ;
83
+ }
84
+ VersionVariables variables ;
85
+ var versionFinder = new GitVersionFinder ( ) ;
86
+ var configuration = ConfigurationProvider . Provide ( projectRoot , fileSystem ) ;
87
+
88
+ using ( var repo = RepositoryLoader . GetRepo ( dotGitDirectory ) )
89
+ {
90
+ var gitVersionContext = new GitVersionContext ( repo , configuration , commitId : commitId ) ;
91
+ var semanticVersion = versionFinder . FindVersion ( gitVersionContext ) ;
92
+ var config = gitVersionContext . Configuration ;
93
+ variables = VariableProvider . GetVariablesFor ( semanticVersion , config . AssemblyVersioningScheme , config . VersioningMode , config . ContinuousDeploymentFallbackTag , gitVersionContext . IsCurrentCommitTagged ) ;
94
+ }
95
+
96
+ return variables ;
87
97
}
88
98
89
99
static bool RunMsBuildIfNeeded ( Arguments args , string workingDirectory , VersionVariables variables )
0 commit comments