Skip to content

Commit e399ab7

Browse files
committed
More logging while preparing the .git directory.
1 parent 628f127 commit e399ab7

File tree

1 file changed

+33
-19
lines changed

1 file changed

+33
-19
lines changed

src/GitVersionCore/GitPreparer.cs

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ public void Initialise(bool normaliseGitDirectory, string currentBranch)
4848
{
4949
if (normaliseGitDirectory)
5050
{
51-
GitRepositoryHelper.NormalizeGitDirectory(GetDotGitDirectory(), authentication, noFetch, currentBranch);
51+
using (Logger.IndentLog(string.Format("Normalizing git directory for branch '{0}'", currentBranch)))
52+
{
53+
GitRepositoryHelper.NormalizeGitDirectory(GetDotGitDirectory(), authentication, noFetch, currentBranch);
54+
}
5255
}
5356
return;
5457
}
@@ -144,23 +147,31 @@ static string CreateDynamicRepository(string targetPath, AuthenticationInfo auth
144147
{
145148
throw new Exception("Dynamic Git repositories must have a target branch (/b)");
146149
}
147-
Logger.WriteInfo(string.Format("Creating dynamic repository at '{0}'", targetPath));
148150

149-
var gitDirectory = Path.Combine(targetPath, ".git");
150-
if (Directory.Exists(targetPath))
151+
using (Logger.IndentLog(string.Format("Creating dynamic repository at '{0}'", targetPath)))
151152
{
152-
Logger.WriteInfo("Git repository already exists");
153-
GitRepositoryHelper.NormalizeGitDirectory(gitDirectory, authentication, noFetch, targetBranch);
153+
var gitDirectory = Path.Combine(targetPath, ".git");
154+
if (Directory.Exists(targetPath))
155+
{
156+
Logger.WriteInfo("Git repository already exists");
157+
using (Logger.IndentLog(string.Format("Normalizing git directory for branch '{0}'", targetBranch)))
158+
{
159+
GitRepositoryHelper.NormalizeGitDirectory(gitDirectory, authentication, noFetch, targetBranch);
160+
}
154161

155-
return gitDirectory;
156-
}
162+
return gitDirectory;
163+
}
157164

158-
CloneRepository(repositoryUrl, gitDirectory, authentication);
165+
CloneRepository(repositoryUrl, gitDirectory, authentication);
159166

160-
// Normalize (download branches) before using the branch
161-
GitRepositoryHelper.NormalizeGitDirectory(gitDirectory, authentication, noFetch, targetBranch);
167+
using (Logger.IndentLog(string.Format("Normalizing git directory for branch '{0}'", targetBranch)))
168+
{
169+
// Normalize (download branches) before using the branch
170+
GitRepositoryHelper.NormalizeGitDirectory(gitDirectory, authentication, noFetch, targetBranch);
171+
}
162172

163-
return gitDirectory;
173+
return gitDirectory;
174+
}
164175
}
165176

166177
static void CloneRepository(string repositoryUrl, string gitDirectory, AuthenticationInfo authentication)
@@ -177,17 +188,20 @@ static void CloneRepository(string repositoryUrl, string gitDirectory, Authentic
177188
};
178189
}
179190

180-
Logger.WriteInfo(string.Format("Retrieving git info from url '{0}'", repositoryUrl));
181191

182192
try
183193
{
184-
var cloneOptions = new CloneOptions
194+
using (Logger.IndentLog(string.Format("Cloning repository from url '{0}'", repositoryUrl)))
185195
{
186-
Checkout = false,
187-
CredentialsProvider = (url, usernameFromUrl, types) => credentials
188-
};
189-
var returnedPath = Repository.Clone(repositoryUrl, gitDirectory, cloneOptions);
190-
Logger.WriteInfo(string.Format("Returned path after repository clone: {0}", returnedPath));
196+
var cloneOptions = new CloneOptions
197+
{
198+
Checkout = false,
199+
CredentialsProvider = (url, usernameFromUrl, types) => credentials
200+
};
201+
202+
var returnedPath = Repository.Clone(repositoryUrl, gitDirectory, cloneOptions);
203+
Logger.WriteInfo(string.Format("Returned path after repository clone: {0}", returnedPath));
204+
}
191205
}
192206
catch (LibGit2SharpException ex)
193207
{

0 commit comments

Comments
 (0)