@@ -4,6 +4,7 @@ namespace GitVersion
44 using System . IO ;
55 using System . Linq ;
66 using GitTools . Git ;
7+ using GitTools . Logging ;
78 using LibGit2Sharp ;
89
910 public class GitPreparer
@@ -28,6 +29,9 @@ public GitPreparer(string targetUrl, string dynamicRepositoryLocation, Authentic
2829 } ;
2930 this . noFetch = noFetch ;
3031 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 ( ) ) ;
3135 }
3236
3337 public string WorkingDirectory
@@ -48,7 +52,10 @@ public void Initialise(bool normaliseGitDirectory, string currentBranch)
4852 {
4953 if ( normaliseGitDirectory )
5054 {
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+ }
5259 }
5360 return ;
5461 }
@@ -144,23 +151,31 @@ static string CreateDynamicRepository(string targetPath, AuthenticationInfo auth
144151 {
145152 throw new Exception ( "Dynamic Git repositories must have a target branch (/b)" ) ;
146153 }
147- Logger . WriteInfo ( string . Format ( "Creating dynamic repository at '{0}'" , targetPath ) ) ;
148154
149- var gitDirectory = Path . Combine ( targetPath , ".git" ) ;
150- if ( Directory . Exists ( targetPath ) )
155+ using ( Logger . IndentLog ( string . Format ( "Creating dynamic repository at '{0}'" , targetPath ) ) )
151156 {
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+ }
154165
155- return gitDirectory ;
156- }
166+ return gitDirectory ;
167+ }
157168
158- CloneRepository ( repositoryUrl , gitDirectory , authentication ) ;
169+ CloneRepository ( repositoryUrl , gitDirectory , authentication ) ;
159170
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+ }
162176
163- return gitDirectory ;
177+ return gitDirectory ;
178+ }
164179 }
165180
166181 static void CloneRepository ( string repositoryUrl , string gitDirectory , AuthenticationInfo authentication )
@@ -181,17 +196,20 @@ static void CloneRepository(string repositoryUrl, string gitDirectory, Authentic
181196 }
182197 }
183198
184- Logger . WriteInfo ( string . Format ( "Retrieving git info from url '{0}'" , repositoryUrl ) ) ;
185199
186200 try
187201 {
188- var cloneOptions = new CloneOptions
202+ using ( Logger . IndentLog ( string . Format ( "Cloning repository from url '{0}'" , repositoryUrl ) ) )
189203 {
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+ }
195213 }
196214 catch ( LibGit2SharpException ex )
197215 {
0 commit comments