Skip to content

Commit

Permalink
replace .Name.Friendly with ToString were it made sens
Browse files Browse the repository at this point in the history
  • Loading branch information
arturcic committed Jan 19, 2021
1 parent 6c05548 commit 001deaf
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/GitVersion.LibGit2Sharp/Git/GitRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public ICommit GetBaseVersionSource(ICommit currentBranchTip)
}
catch (NotFoundException exception)
{
throw new GitVersionException($"Cannot find commit {currentBranchTip.Sha}. Please ensure that the repository is an unshallow clone with `git fetch --unshallow`.", exception);
throw new GitVersionException($"Cannot find commit {currentBranchTip}. Please ensure that the repository is an unshallow clone with `git fetch --unshallow`.", exception);
}
}
public IEnumerable<ICommit> GetMainlineCommitLog(ICommit baseVersionSource, ICommit mainlineTip)
Expand Down
2 changes: 1 addition & 1 deletion src/GitVersionCore.Tests/Core/RepositoryExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private static void EnsureLocalBranchExistsForCurrentBranch(IGitRepository repo,
}
else
{
log.Info(isBranch ? $"Updating local branch {localCanonicalName} to point at {repoTip.Sha}"
log.Info(isBranch ? $"Updating local branch {localCanonicalName} to point at {repoTip}"
: $"Updating local branch {localCanonicalName} to match ref {currentBranch}");
var localRef = repo.Refs[localCanonicalName];
repo.Refs.UpdateTarget(localRef, repoTipId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public BranchConfig GetBranchConfiguration(IBranch targetBranch, ICommit current

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

matchingBranches = BranchConfig.CreateDefaultBranchConfig(FallbackConfigName)
.Apply(new BranchConfig
Expand Down Expand Up @@ -103,7 +103,7 @@ private BranchConfig InheritBranchConfiguration(IBranch targetBranch, BranchConf
}
}

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

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

var chosenBranch = repositoryMetadataProvider.GetChosenBranch(configuration);
if (chosenBranch == null)
Expand Down Expand Up @@ -204,7 +204,7 @@ private IBranch[] CalculateWhenMultipleParents(ICommit currentCommit, ref IBranc
}
}

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

return excludedBranches;
}
Expand Down
4 changes: 2 additions & 2 deletions src/GitVersionCore/Core/GitPreparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private void NormalizeGitDirectory(string gitDirectory, bool noFetch, string cur
}
else
{
log.Info($"Checking out local branch 'refs/heads/{localBranchesWhereCommitShaIsHead[0].Name.Friendly}'.");
log.Info($"Checking out local branch 'refs/heads/{localBranchesWhereCommitShaIsHead[0]}'.");
repository.Checkout(repository.Branches[localBranchesWhereCommitShaIsHead[0].Name.Friendly]);
}
}
Expand Down Expand Up @@ -346,7 +346,7 @@ private static void EnsureLocalBranchExistsForCurrentBranch(IGitRepository repo,
}
else
{
log.Info(isBranch ? $"Updating local branch {localCanonicalName} to point at {repoTip.Sha}"
log.Info(isBranch ? $"Updating local branch {localCanonicalName} to point at {repoTip}"
: $"Updating local branch {localCanonicalName} to match ref {currentBranch}");
var localRef = repo.Refs[localCanonicalName];
repo.Refs.UpdateTarget(localRef, repoTipId);
Expand Down
30 changes: 15 additions & 15 deletions src/GitVersionCore/Core/RepositoryMetadataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public ICommit FindMergeBase(IBranch branch, IBranch otherBranch)

if (mergeBaseCache.ContainsKey(key))
{
log.Debug($"Cache hit for merge base between '{branch.Name.Friendly}' and '{otherBranch.Name.Friendly}'.");
log.Debug($"Cache hit for merge base between '{branch}' and '{otherBranch}'.");
return mergeBaseCache[key].MergeBase;
}

using (log.IndentLog($"Finding merge base between '{branch.Name.Friendly}' and '{otherBranch.Name.Friendly}'."))
using (log.IndentLog($"Finding merge base between '{branch}' and '{otherBranch}'."))
{
// Otherbranch tip is a forward merge
var commitToFindCommonBase = otherBranch.Tip;
Expand All @@ -53,7 +53,7 @@ public ICommit FindMergeBase(IBranch branch, IBranch otherBranch)
var findMergeBase = repository.FindMergeBase(commit, commitToFindCommonBase);
if (findMergeBase != null)
{
log.Info($"Found merge base of {findMergeBase.Sha}");
log.Info($"Found merge base of {findMergeBase}");
// We do not want to include merge base commits which got forward merged into the other branch
ICommit forwardMerge;
do
Expand All @@ -65,15 +65,15 @@ public ICommit FindMergeBase(IBranch branch, IBranch otherBranch)
{
// TODO Fix the logging up in this section
var second = forwardMerge.Parents.First();
log.Debug("Second " + second.Sha);
log.Debug($"Second {second}");
var mergeBase = repository.FindMergeBase(commit, second);
if (mergeBase == null)
{
log.Warning("Could not find mergbase for " + commit);
}
else
{
log.Debug("New Merge base " + mergeBase.Sha);
log.Debug($"New Merge base {mergeBase}");
}
if (Equals(mergeBase, findMergeBase))
{
Expand All @@ -90,7 +90,7 @@ public ICommit FindMergeBase(IBranch branch, IBranch otherBranch)
// Store in cache.
mergeBaseCache.Add(key, new MergeBaseData(findMergeBase));

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

directBranchHasBeenFound = true;
log.Info($"Direct branch found: '{branch.Name.Friendly}'.");
log.Info($"Direct branch found: '{branch}'.");
yield return branch;
}

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

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

if (!commits.Any())
{
log.Info($"The branch '{branch.Name.Friendly}' has no matching commits.");
log.Info($"The branch '{branch}' has no matching commits.");
continue;
}

log.Info($"The branch '{branch.Name.Friendly}' has a matching commit.");
log.Info($"The branch '{branch}' has a matching commit.");
yield return branch;
}
}
Expand Down Expand Up @@ -296,11 +296,11 @@ public BranchCommit FindCommitBranchWasBranchedFrom(IBranch branch, Config confi
throw new ArgumentNullException(nameof(branch));
}

using (log.IndentLog($"Finding branch source of '{branch.Name.Friendly}'"))
using (log.IndentLog($"Finding branch source of '{branch}'"))
{
if (branch.Tip == null)
{
log.Warning(string.Format(MissingTipFormat, branch.Name.Friendly));
log.Warning(string.Format(MissingTipFormat, branch));
return BranchCommit.Empty;
}

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

Expand Down Expand Up @@ -429,7 +429,7 @@ private IEnumerable<BranchCommit> GetMergeCommitsForBranch(IBranch branch, Confi
{
if (otherBranch.Tip == null)
{
log.Warning(string.Format(MissingTipFormat, otherBranch.Name.Friendly));
log.Warning(string.Format(MissingTipFormat, otherBranch));
return BranchCommit.Empty;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override IEnumerable<BaseVersion> GetVersions()
mergeMessage.Version != null &&
Context.FullConfiguration.IsReleaseBranch(TrimRemote(mergeMessage.MergedBranch)))
{
log.Info($"Found commit [{Context.CurrentCommit.Sha}] matching merge message format: {mergeMessage.FormatName}");
log.Info($"Found commit [{Context.CurrentCommit}] matching merge message format: {mergeMessage.FormatName}");
var shouldIncrement = !Context.Configuration.PreventIncrementForMergedBranchVersion;
return new[]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public SemanticVersion FindMainlineModeVersion(BaseVersion baseVersion)
if (!context.CurrentBranch.Equals(mainline))
{
mergeBase = FindMergeBaseBeforeForwardMerge(baseVersion.BaseVersionSource, mainline, out mainlineTip);
log.Info($"Current branch ({context.CurrentBranch.Name.Friendly}) was branch from {mergeBase}");
log.Info($"Current branch ({context.CurrentBranch}) was branch from {mergeBase}");
}

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

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

// Finally increment for the branch
mainlineVersion = mainlineVersion.IncrementVersion(findMessageIncrement);
log.Info($"Merge commit {mergeCommit.Sha} incremented base versions {findMessageIncrement}, now {mainlineVersion}");
log.Info($"Merge commit {mergeCommit} incremented base versions {findMessageIncrement}, now {mainlineVersion}");
return mainlineVersion;
}

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

// prefer current branch, if it is a mainline branch
if (possibleMainlineBranches.Any(context.CurrentBranch.Equals))
{
log.Info($"Choosing {context.CurrentBranch.Name.Friendly} as mainline because it is the current branch");
log.Info($"Choosing {context.CurrentBranch} as mainline because it is the current branch");
return context.CurrentBranch;
}

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

return firstMatchingCommitBranch;
}

var chosenMainline = possibleMainlineBranches[0];
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...");
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...");
return chosenMainline;
}

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

return mainlineVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class NextVersionCalculator : INextVersionCalculator

public SemanticVersion FindVersion()
{
log.Info($"Running against branch: {context.CurrentBranch.Name.Friendly} ({(context.CurrentCommit == null ? "-" : context.CurrentCommit.Sha)})");
log.Info($"Running against branch: {context.CurrentBranch} ({(context.CurrentCommit != null ? context.CurrentCommit.ToString() : "-")})");
if (context.IsCurrentCommitTagged)
{
log.Info($"Current commit is tagged with version {context.CurrentCommitTaggedVersion}, " +
Expand Down
2 changes: 1 addition & 1 deletion src/GitVersionCore/VersionCalculation/ShaVersionFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public bool Exclude(BaseVersion version, out string reason)
if (version.BaseVersionSource != null &&
shas.Any(sha => version.BaseVersionSource.Sha.StartsWith(sha, StringComparison.OrdinalIgnoreCase)))
{
reason = $"Sha {version.BaseVersionSource.Sha} was ignored due to commit having been excluded by configuration";
reason = $"Sha {version.BaseVersionSource} was ignored due to commit having been excluded by configuration";
return true;
}

Expand Down

0 comments on commit 001deaf

Please sign in to comment.