Skip to content

Commit 001deaf

Browse files
committed
replace .Name.Friendly with ToString were it made sens
1 parent 6c05548 commit 001deaf

File tree

9 files changed

+35
-35
lines changed

9 files changed

+35
-35
lines changed

src/GitVersion.LibGit2Sharp/Git/GitRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public ICommit GetBaseVersionSource(ICommit currentBranchTip)
335335
}
336336
catch (NotFoundException exception)
337337
{
338-
throw new GitVersionException($"Cannot find commit {currentBranchTip.Sha}. Please ensure that the repository is an unshallow clone with `git fetch --unshallow`.", exception);
338+
throw new GitVersionException($"Cannot find commit {currentBranchTip}. Please ensure that the repository is an unshallow clone with `git fetch --unshallow`.", exception);
339339
}
340340
}
341341
public IEnumerable<ICommit> GetMainlineCommitLog(ICommit baseVersionSource, ICommit mainlineTip)

src/GitVersionCore.Tests/Core/RepositoryExtensionsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private static void EnsureLocalBranchExistsForCurrentBranch(IGitRepository repo,
5555
}
5656
else
5757
{
58-
log.Info(isBranch ? $"Updating local branch {localCanonicalName} to point at {repoTip.Sha}"
58+
log.Info(isBranch ? $"Updating local branch {localCanonicalName} to point at {repoTip}"
5959
: $"Updating local branch {localCanonicalName} to match ref {currentBranch}");
6060
var localRef = repo.Refs[localCanonicalName];
6161
repo.Refs.UpdateTarget(localRef, repoTipId);

src/GitVersionCore/Configuration/BranchConfigurationCalculator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public BranchConfig GetBranchConfiguration(IBranch targetBranch, ICommit current
3131

3232
if (matchingBranches == null)
3333
{
34-
log.Info($"No branch configuration found for branch {targetBranch.Name.Friendly}, falling back to default configuration");
34+
log.Info($"No branch configuration found for branch {targetBranch}, falling back to default configuration");
3535

3636
matchingBranches = BranchConfig.CreateDefaultBranchConfig(FallbackConfigName)
3737
.Apply(new BranchConfig
@@ -103,7 +103,7 @@ private BranchConfig InheritBranchConfiguration(IBranch targetBranch, BranchConf
103103
}
104104
}
105105

106-
log.Info("Found possible parent branches: " + string.Join(", ", possibleParents.Select(p => p.Name.Friendly)));
106+
log.Info("Found possible parent branches: " + string.Join(", ", possibleParents.Select(p => p.ToString())));
107107

108108
if (possibleParents.Count == 1)
109109
{
@@ -125,7 +125,7 @@ private BranchConfig InheritBranchConfiguration(IBranch targetBranch, BranchConf
125125
// if develop exists and master if not
126126
var errorMessage = possibleParents.Count == 0
127127
? "Failed to inherit Increment branch configuration, no branches found."
128-
: "Failed to inherit Increment branch configuration, ended up with: " + string.Join(", ", possibleParents.Select(p => p.Name.Friendly));
128+
: "Failed to inherit Increment branch configuration, ended up with: " + string.Join(", ", possibleParents.Select(p => p.ToString()));
129129

130130
var chosenBranch = repositoryMetadataProvider.GetChosenBranch(configuration);
131131
if (chosenBranch == null)
@@ -204,7 +204,7 @@ private IBranch[] CalculateWhenMultipleParents(ICommit currentCommit, ref IBranc
204204
}
205205
}
206206

207-
log.Info("HEAD is merge commit, this is likely a pull request using " + currentBranch.Name.Friendly + " as base");
207+
log.Info($"HEAD is merge commit, this is likely a pull request using {currentBranch} as base");
208208

209209
return excludedBranches;
210210
}

src/GitVersionCore/Core/GitPreparer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ private void NormalizeGitDirectory(string gitDirectory, bool noFetch, string cur
244244
}
245245
else
246246
{
247-
log.Info($"Checking out local branch 'refs/heads/{localBranchesWhereCommitShaIsHead[0].Name.Friendly}'.");
247+
log.Info($"Checking out local branch 'refs/heads/{localBranchesWhereCommitShaIsHead[0]}'.");
248248
repository.Checkout(repository.Branches[localBranchesWhereCommitShaIsHead[0].Name.Friendly]);
249249
}
250250
}
@@ -346,7 +346,7 @@ private static void EnsureLocalBranchExistsForCurrentBranch(IGitRepository repo,
346346
}
347347
else
348348
{
349-
log.Info(isBranch ? $"Updating local branch {localCanonicalName} to point at {repoTip.Sha}"
349+
log.Info(isBranch ? $"Updating local branch {localCanonicalName} to point at {repoTip}"
350350
: $"Updating local branch {localCanonicalName} to match ref {currentBranch}");
351351
var localRef = repo.Refs[localCanonicalName];
352352
repo.Refs.UpdateTarget(localRef, repoTipId);

src/GitVersionCore/Core/RepositoryMetadataProvider.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ public ICommit FindMergeBase(IBranch branch, IBranch otherBranch)
3636

3737
if (mergeBaseCache.ContainsKey(key))
3838
{
39-
log.Debug($"Cache hit for merge base between '{branch.Name.Friendly}' and '{otherBranch.Name.Friendly}'.");
39+
log.Debug($"Cache hit for merge base between '{branch}' and '{otherBranch}'.");
4040
return mergeBaseCache[key].MergeBase;
4141
}
4242

43-
using (log.IndentLog($"Finding merge base between '{branch.Name.Friendly}' and '{otherBranch.Name.Friendly}'."))
43+
using (log.IndentLog($"Finding merge base between '{branch}' and '{otherBranch}'."))
4444
{
4545
// Otherbranch tip is a forward merge
4646
var commitToFindCommonBase = otherBranch.Tip;
@@ -53,7 +53,7 @@ public ICommit FindMergeBase(IBranch branch, IBranch otherBranch)
5353
var findMergeBase = repository.FindMergeBase(commit, commitToFindCommonBase);
5454
if (findMergeBase != null)
5555
{
56-
log.Info($"Found merge base of {findMergeBase.Sha}");
56+
log.Info($"Found merge base of {findMergeBase}");
5757
// We do not want to include merge base commits which got forward merged into the other branch
5858
ICommit forwardMerge;
5959
do
@@ -65,15 +65,15 @@ public ICommit FindMergeBase(IBranch branch, IBranch otherBranch)
6565
{
6666
// TODO Fix the logging up in this section
6767
var second = forwardMerge.Parents.First();
68-
log.Debug("Second " + second.Sha);
68+
log.Debug($"Second {second}");
6969
var mergeBase = repository.FindMergeBase(commit, second);
7070
if (mergeBase == null)
7171
{
7272
log.Warning("Could not find mergbase for " + commit);
7373
}
7474
else
7575
{
76-
log.Debug("New Merge base " + mergeBase.Sha);
76+
log.Debug($"New Merge base {mergeBase}");
7777
}
7878
if (Equals(mergeBase, findMergeBase))
7979
{
@@ -90,7 +90,7 @@ public ICommit FindMergeBase(IBranch branch, IBranch otherBranch)
9090
// Store in cache.
9191
mergeBaseCache.Add(key, new MergeBaseData(findMergeBase));
9292

93-
log.Info($"Merge base of {branch.Name.Friendly}' and '{otherBranch.Name.Friendly} is {findMergeBase}");
93+
log.Info($"Merge base of {branch}' and '{otherBranch} is {findMergeBase}");
9494
return findMergeBase;
9595
}
9696
}
@@ -240,7 +240,7 @@ public IEnumerable<IBranch> GetBranchesContainingCommit(ICommit commit, IEnumera
240240
}
241241

242242
directBranchHasBeenFound = true;
243-
log.Info($"Direct branch found: '{branch.Name.Friendly}'.");
243+
log.Info($"Direct branch found: '{branch}'.");
244244
yield return branch;
245245
}
246246

@@ -252,17 +252,17 @@ public IEnumerable<IBranch> GetBranchesContainingCommit(ICommit commit, IEnumera
252252
log.Info($"No direct branches found, searching through {(onlyTrackedBranches ? "tracked" : "all")} branches.");
253253
foreach (var branch in branchList.Where(b => IncludeTrackedBranches(b, onlyTrackedBranches)))
254254
{
255-
log.Info($"Searching for commits reachable from '{branch.Name.Friendly}'.");
255+
log.Info($"Searching for commits reachable from '{branch}'.");
256256

257257
var commits = repository.GetCommitsReacheableFrom(commit, branch);
258258

259259
if (!commits.Any())
260260
{
261-
log.Info($"The branch '{branch.Name.Friendly}' has no matching commits.");
261+
log.Info($"The branch '{branch}' has no matching commits.");
262262
continue;
263263
}
264264

265-
log.Info($"The branch '{branch.Name.Friendly}' has a matching commit.");
265+
log.Info($"The branch '{branch}' has a matching commit.");
266266
yield return branch;
267267
}
268268
}
@@ -296,11 +296,11 @@ public BranchCommit FindCommitBranchWasBranchedFrom(IBranch branch, Config confi
296296
throw new ArgumentNullException(nameof(branch));
297297
}
298298

299-
using (log.IndentLog($"Finding branch source of '{branch.Name.Friendly}'"))
299+
using (log.IndentLog($"Finding branch source of '{branch}'"))
300300
{
301301
if (branch.Tip == null)
302302
{
303-
log.Warning(string.Format(MissingTipFormat, branch.Name.Friendly));
303+
log.Warning(string.Format(MissingTipFormat, branch));
304304
return BranchCommit.Empty;
305305
}
306306

@@ -311,9 +311,9 @@ public BranchCommit FindCommitBranchWasBranchedFrom(IBranch branch, Config confi
311311
if (possibleBranches.Count > 1)
312312
{
313313
var first = possibleBranches.First();
314-
log.Info($"Multiple source branches have been found, picking the first one ({first.Branch.Name.Friendly}).{System.Environment.NewLine}" +
314+
log.Info($"Multiple source branches have been found, picking the first one ({first.Branch}).{System.Environment.NewLine}" +
315315
$"This may result in incorrect commit counting.{System.Environment.NewLine}Options were:{System.Environment.NewLine}" +
316-
string.Join(", ", possibleBranches.Select(b => b.Branch.Name.Friendly)));
316+
string.Join(", ", possibleBranches.Select(b => b.Branch.ToString())));
317317
return first;
318318
}
319319

@@ -429,7 +429,7 @@ private IEnumerable<BranchCommit> GetMergeCommitsForBranch(IBranch branch, Confi
429429
{
430430
if (otherBranch.Tip == null)
431431
{
432-
log.Warning(string.Format(MissingTipFormat, otherBranch.Name.Friendly));
432+
log.Warning(string.Format(MissingTipFormat, otherBranch));
433433
return BranchCommit.Empty;
434434
}
435435

src/GitVersionCore/VersionCalculation/BaseVersionCalculators/MergeMessageVersionStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public override IEnumerable<BaseVersion> GetVersions()
3232
mergeMessage.Version != null &&
3333
Context.FullConfiguration.IsReleaseBranch(TrimRemote(mergeMessage.MergedBranch)))
3434
{
35-
log.Info($"Found commit [{Context.CurrentCommit.Sha}] matching merge message format: {mergeMessage.FormatName}");
35+
log.Info($"Found commit [{Context.CurrentCommit}] matching merge message format: {mergeMessage.FormatName}");
3636
var shouldIncrement = !Context.Configuration.PreventIncrementForMergedBranchVersion;
3737
return new[]
3838
{

src/GitVersionCore/VersionCalculation/MainlineVersionCalculator.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public SemanticVersion FindMainlineModeVersion(BaseVersion baseVersion)
4646
if (!context.CurrentBranch.Equals(mainline))
4747
{
4848
mergeBase = FindMergeBaseBeforeForwardMerge(baseVersion.BaseVersionSource, mainline, out mainlineTip);
49-
log.Info($"Current branch ({context.CurrentBranch.Name.Friendly}) was branch from {mergeBase}");
49+
log.Info($"Current branch ({context.CurrentBranch}) was branch from {mergeBase}");
5050
}
5151

5252
var mainlineCommitLog = repositoryMetadataProvider.GetMainlineCommitLog(baseVersion.BaseVersionSource, mainlineTip).ToList();
@@ -87,7 +87,7 @@ public SemanticVersionBuildMetaData CreateVersionBuildMetaData(ICommit baseVersi
8787
{
8888
var commitLog = repositoryMetadataProvider.GetCommitLog(baseVersionSource, context.CurrentCommit);
8989
var commitsSinceTag = commitLog.Count();
90-
log.Info($"{commitsSinceTag} commits found between {baseVersionSource.Sha} and {context.CurrentCommit.Sha}");
90+
log.Info($"{commitsSinceTag} commits found between {baseVersionSource} and {context.CurrentCommit}");
9191

9292
var shortSha = repositoryMetadataProvider.ShortenObjectId(context.CurrentCommit);
9393
return new SemanticVersionBuildMetaData(
@@ -116,7 +116,7 @@ private SemanticVersion AggregateMergeCommitIncrement(ICommit commit, List<IComm
116116

117117
// Finally increment for the branch
118118
mainlineVersion = mainlineVersion.IncrementVersion(findMessageIncrement);
119-
log.Info($"Merge commit {mergeCommit.Sha} incremented base versions {findMessageIncrement}, now {mainlineVersion}");
119+
log.Info($"Merge commit {mergeCommit} incremented base versions {findMessageIncrement}, now {mainlineVersion}");
120120
return mainlineVersion;
121121
}
122122

@@ -135,14 +135,14 @@ private IBranch GetMainline(ICommit baseVersionSource)
135135
if (possibleMainlineBranches.Count == 1)
136136
{
137137
var mainlineBranch = possibleMainlineBranches[0];
138-
log.Info("Mainline for current branch is " + mainlineBranch.Name.Friendly);
138+
log.Info($"Mainline for current branch is {mainlineBranch}");
139139
return mainlineBranch;
140140
}
141141

142142
// prefer current branch, if it is a mainline branch
143143
if (possibleMainlineBranches.Any(context.CurrentBranch.Equals))
144144
{
145-
log.Info($"Choosing {context.CurrentBranch.Name.Friendly} as mainline because it is the current branch");
145+
log.Info($"Choosing {context.CurrentBranch} as mainline because it is the current branch");
146146
return context.CurrentBranch;
147147
}
148148

@@ -152,15 +152,15 @@ private IBranch GetMainline(ICommit baseVersionSource)
152152
{
153153
var message = string.Format(
154154
"Choosing {0} as mainline because {1}'s merge base was a direct commit to {0}",
155-
firstMatchingCommitBranch.Name.Friendly,
156-
context.CurrentBranch.Name.Friendly);
155+
firstMatchingCommitBranch,
156+
context.CurrentBranch);
157157
log.Info(message);
158158

159159
return firstMatchingCommitBranch;
160160
}
161161

162162
var chosenMainline = possibleMainlineBranches[0];
163-
log.Info($"Multiple mainlines ({string.Join(", ", possibleMainlineBranches.Select(b => b.Name.Friendly))}) have the same merge base for the current branch, choosing {chosenMainline.Name.Friendly} because we found that branch first...");
163+
log.Info($"Multiple mainlines ({string.Join(", ", possibleMainlineBranches.Select(b => b))}) have the same merge base for the current branch, choosing {chosenMainline} because we found that branch first...");
164164
return chosenMainline;
165165
}
166166

@@ -231,7 +231,7 @@ private SemanticVersion IncrementForEachCommit(IEnumerable<ICommit> directCommit
231231
var directCommitIncrement = IncrementStrategyFinder.GetIncrementForCommits(context, new[] { directCommit })
232232
?? FindDefaultIncrementForBranch(context, mainline.Name.Friendly);
233233
mainlineVersion = mainlineVersion.IncrementVersion(directCommitIncrement);
234-
log.Info($"Direct commit on master {directCommit.Sha} incremented base versions {directCommitIncrement}, now {mainlineVersion}");
234+
log.Info($"Direct commit on master {directCommit} incremented base versions {directCommitIncrement}, now {mainlineVersion}");
235235
}
236236

237237
return mainlineVersion;

src/GitVersionCore/VersionCalculation/NextVersionCalculator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public NextVersionCalculator(ILog log, IBaseVersionCalculator baseVersionCalcula
2929

3030
public SemanticVersion FindVersion()
3131
{
32-
log.Info($"Running against branch: {context.CurrentBranch.Name.Friendly} ({(context.CurrentCommit == null ? "-" : context.CurrentCommit.Sha)})");
32+
log.Info($"Running against branch: {context.CurrentBranch} ({(context.CurrentCommit != null ? context.CurrentCommit.ToString() : "-")})");
3333
if (context.IsCurrentCommitTagged)
3434
{
3535
log.Info($"Current commit is tagged with version {context.CurrentCommitTaggedVersion}, " +

src/GitVersionCore/VersionCalculation/ShaVersionFilter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public bool Exclude(BaseVersion version, out string reason)
2222
if (version.BaseVersionSource != null &&
2323
shas.Any(sha => version.BaseVersionSource.Sha.StartsWith(sha, StringComparison.OrdinalIgnoreCase)))
2424
{
25-
reason = $"Sha {version.BaseVersionSource.Sha} was ignored due to commit having been excluded by configuration";
25+
reason = $"Sha {version.BaseVersionSource} was ignored due to commit having been excluded by configuration";
2626
return true;
2727
}
2828

0 commit comments

Comments
 (0)