@@ -4,6 +4,7 @@ namespace GitVersion
4
4
using System . IO ;
5
5
using System . Linq ;
6
6
using GitTools . Git ;
7
+ using GitTools . Logging ;
7
8
using LibGit2Sharp ;
8
9
9
10
public class GitPreparer
@@ -28,6 +29,9 @@ public GitPreparer(string targetUrl, string dynamicRepositoryLocation, Authentic
28
29
} ;
29
30
this . noFetch = noFetch ;
30
31
this . targetPath = targetPath . TrimEnd ( '/' , '\\ ' ) ;
32
+
33
+ // GitTools has its own logging. So that it actually outputs something, it needs to be initialized.
34
+ LogProvider . SetCurrentLogProvider ( new LoggerWrapper ( ) ) ;
31
35
}
32
36
33
37
public string WorkingDirectory
@@ -48,7 +52,10 @@ public void Initialise(bool normaliseGitDirectory, string currentBranch)
48
52
{
49
53
if ( normaliseGitDirectory )
50
54
{
51
- GitRepositoryHelper . NormalizeGitDirectory ( GetDotGitDirectory ( ) , authentication , noFetch , currentBranch ) ;
55
+ using ( Logger . IndentLog ( string . Format ( "Normalizing git directory for branch '{0}'" , currentBranch ) ) )
56
+ {
57
+ GitRepositoryHelper . NormalizeGitDirectory ( GetDotGitDirectory ( ) , authentication , noFetch , currentBranch ) ;
58
+ }
52
59
}
53
60
return ;
54
61
}
@@ -144,23 +151,31 @@ static string CreateDynamicRepository(string targetPath, AuthenticationInfo auth
144
151
{
145
152
throw new Exception ( "Dynamic Git repositories must have a target branch (/b)" ) ;
146
153
}
147
- Logger . WriteInfo ( string . Format ( "Creating dynamic repository at '{0}'" , targetPath ) ) ;
148
154
149
- var gitDirectory = Path . Combine ( targetPath , ".git" ) ;
150
- if ( Directory . Exists ( targetPath ) )
155
+ using ( Logger . IndentLog ( string . Format ( "Creating dynamic repository at '{0}'" , targetPath ) ) )
151
156
{
152
- Logger . WriteInfo ( "Git repository already exists" ) ;
153
- GitRepositoryHelper . NormalizeGitDirectory ( gitDirectory , authentication , noFetch , targetBranch ) ;
157
+ var gitDirectory = Path . Combine ( targetPath , ".git" ) ;
158
+ if ( Directory . Exists ( targetPath ) )
159
+ {
160
+ Logger . WriteInfo ( "Git repository already exists" ) ;
161
+ using ( Logger . IndentLog ( string . Format ( "Normalizing git directory for branch '{0}'" , targetBranch ) ) )
162
+ {
163
+ GitRepositoryHelper . NormalizeGitDirectory ( gitDirectory , authentication , noFetch , targetBranch ) ;
164
+ }
154
165
155
- return gitDirectory ;
156
- }
166
+ return gitDirectory ;
167
+ }
157
168
158
- CloneRepository ( repositoryUrl , gitDirectory , authentication ) ;
169
+ CloneRepository ( repositoryUrl , gitDirectory , authentication ) ;
159
170
160
- // Normalize (download branches) before using the branch
161
- GitRepositoryHelper . NormalizeGitDirectory ( gitDirectory , authentication , noFetch , targetBranch ) ;
171
+ using ( Logger . IndentLog ( string . Format ( "Normalizing git directory for branch '{0}'" , targetBranch ) ) )
172
+ {
173
+ // Normalize (download branches) before using the branch
174
+ GitRepositoryHelper . NormalizeGitDirectory ( gitDirectory , authentication , noFetch , targetBranch ) ;
175
+ }
162
176
163
- return gitDirectory ;
177
+ return gitDirectory ;
178
+ }
164
179
}
165
180
166
181
static void CloneRepository ( string repositoryUrl , string gitDirectory , AuthenticationInfo authentication )
@@ -181,17 +196,20 @@ static void CloneRepository(string repositoryUrl, string gitDirectory, Authentic
181
196
}
182
197
}
183
198
184
- Logger . WriteInfo ( string . Format ( "Retrieving git info from url '{0}'" , repositoryUrl ) ) ;
185
199
186
200
try
187
201
{
188
- var cloneOptions = new CloneOptions
202
+ using ( Logger . IndentLog ( string . Format ( "Cloning repository from url '{0}'" , repositoryUrl ) ) )
189
203
{
190
- Checkout = false ,
191
- CredentialsProvider = ( url , usernameFromUrl , types ) => credentials
192
- } ;
193
- var returnedPath = Repository . Clone ( repositoryUrl , gitDirectory , cloneOptions ) ;
194
- Logger . WriteInfo ( string . Format ( "Returned path after repository clone: {0}" , returnedPath ) ) ;
204
+ var cloneOptions = new CloneOptions
205
+ {
206
+ Checkout = false ,
207
+ CredentialsProvider = ( url , usernameFromUrl , types ) => credentials
208
+ } ;
209
+
210
+ var returnedPath = Repository . Clone ( repositoryUrl , gitDirectory , cloneOptions ) ;
211
+ Logger . WriteInfo ( string . Format ( "Returned path after repository clone: {0}" , returnedPath ) ) ;
212
+ }
195
213
}
196
214
catch ( LibGit2SharpException ex )
197
215
{
0 commit comments