Skip to content

Commit d8c600a

Browse files
committed
Cleanup.
Fix typos, remove unused usings, invoke extension methods properly.
1 parent 31fc1ed commit d8c600a

File tree

8 files changed

+33
-36
lines changed

8 files changed

+33
-36
lines changed

src/GitVersionCore.Tests/ConfigProviderTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public void WarnOnObsoleteIsDevelopBranchConfigurationSetting()
322322
LegacyConfigNotifier.Notify(new StringReader(text));
323323
});
324324

325-
var expecedMessage = string.Format("'is-develop' is deprecated, use 'track-release-branches' instead.");
326-
exception.Message.ShouldContain(expecedMessage);
325+
const string expectedMessage = @"'is-develop' is deprecated, use 'track-release-branches' instead.";
326+
exception.Message.ShouldContain(expectedMessage);
327327
}
328328
}

src/GitVersionCore/BranchConfigurationCalculator.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,25 +92,25 @@ static BranchConfig InheritBranchConfiguration(GitVersionContext context, Branch
9292
}
9393
var branchesToEvaluate = repository.Branches.Except(excludedInheritBranches).ToList();
9494

95-
var branchPoint = context.RepostioryMetadataProvider
96-
.FindCommitBranchWasBranchedFrom(targetBranch, repository, excludedInheritBranches.ToArray());
95+
var branchPoint = context.RepositoryMetadataProvider
96+
.FindCommitBranchWasBranchedFrom(targetBranch, excludedInheritBranches.ToArray());
9797
List<Branch> possibleParents;
9898
if (branchPoint == BranchCommit.Empty)
9999
{
100-
possibleParents = context.RepostioryMetadataProvider.GetBranchesContainingCommit(context.CurrentCommit, repository, branchesToEvaluate, true)
100+
possibleParents = context.RepositoryMetadataProvider.GetBranchesContainingCommit(context.CurrentCommit, branchesToEvaluate, true)
101101
// It fails to inherit Increment branch configuration if more than 1 parent;
102102
// therefore no point to get more than 2 parents
103103
.Take(2)
104104
.ToList();
105105
}
106106
else
107107
{
108-
var branches = context.RepostioryMetadataProvider
109-
.GetBranchesContainingCommit(branchPoint.Commit, repository, branchesToEvaluate, true).ToList();
108+
var branches = context.RepositoryMetadataProvider
109+
.GetBranchesContainingCommit(branchPoint.Commit, branchesToEvaluate, true).ToList();
110110
if (branches.Count > 1)
111111
{
112-
var currentTipBranches = context.RepostioryMetadataProvider
113-
.GetBranchesContainingCommit(context.CurrentCommit, repository, branchesToEvaluate, true).ToList();
112+
var currentTipBranches = context.RepositoryMetadataProvider
113+
.GetBranchesContainingCommit(context.CurrentCommit, branchesToEvaluate, true).ToList();
114114
possibleParents = branches.Except(currentTipBranches).ToList();
115115
}
116116
else
@@ -154,7 +154,7 @@ static BranchConfig InheritBranchConfiguration(GitVersionContext context, Branch
154154
Logger.WriteWarning(errorMessage + Environment.NewLine + Environment.NewLine + "Falling back to " + branchName + " branch config");
155155

156156
// To prevent infinite loops, make sure that a new branch was chosen.
157-
if (LibGitExtensions.IsSameBranch(targetBranch, chosenBranch))
157+
if (targetBranch.IsSameBranch(chosenBranch))
158158
{
159159
Logger.WriteWarning("Fallback branch wants to inherit Increment branch configuration from itself. Using patch increment instead.");
160160
return new BranchConfig(branchConfiguration)

src/GitVersionCore/Configuration/ConfigurationProvider.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ namespace GitVersion
22
{
33
using Configuration.Init.Wizard;
44
using GitVersion.Helpers;
5-
using System;
65
using System.IO;
76
using System.Linq;
87
using System.Text;

src/GitVersionCore/GitRepoMetadataProvider.cs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@ public class GitRepoMetadataProvider
1111
private Dictionary<Branch, List<BranchCommit>> mergeBaseCommitsCache;
1212
private Dictionary<Tuple<Branch, Branch>, MergeBaseData> mergeBaseCache;
1313
private Dictionary<Branch, List<SemanticVersion>> semanticVersionTagsOnBranchCache;
14-
private IRepository repository;
14+
private IRepository Repository { get; set; }
1515
const string missingTipFormat = "{0} has no tip. Please see http://example.com/docs for information on how to fix this.";
1616

17-
1817
public GitRepoMetadataProvider(IRepository repository)
1918
{
2019
mergeBaseCache = new Dictionary<Tuple<Branch, Branch>, MergeBaseData>();
2120
mergeBaseCommitsCache = new Dictionary<Branch, List<BranchCommit>>();
2221
semanticVersionTagsOnBranchCache = new Dictionary<Branch, List<SemanticVersion>>();
23-
this.repository = repository;
22+
this.Repository = repository;
2423
}
2524

26-
public IEnumerable<SemanticVersion> GetVersionTagsOnBranch(Branch branch, IRepository repository, string tagPrefixRegex)
25+
public IEnumerable<SemanticVersion> GetVersionTagsOnBranch(Branch branch, string tagPrefixRegex)
2726
{
2827
if (semanticVersionTagsOnBranchCache.ContainsKey(branch))
2928
{
@@ -33,9 +32,9 @@ public IEnumerable<SemanticVersion> GetVersionTagsOnBranch(Branch branch, IRepos
3332

3433
using (Logger.IndentLog(string.Format("Getting version tags from branch '{0}'.", branch.CanonicalName)))
3534
{
36-
var tags = repository.Tags.Select(t => t).ToList();
35+
var tags = this.Repository.Tags.Select(t => t).ToList();
3736

38-
var versionTags = repository.Commits.QueryBy(new CommitFilter
37+
var versionTags = this.Repository.Commits.QueryBy(new CommitFilter
3938
{
4039
IncludeReachableFrom = branch.Tip
4140
})
@@ -53,13 +52,13 @@ public IEnumerable<SemanticVersion> GetVersionTagsOnBranch(Branch branch, IRepos
5352
}
5453

5554
// TODO Should we cache this?
56-
public IEnumerable<Branch> GetBranchesContainingCommit([NotNull] Commit commit, IRepository repository, IList<Branch> branches, bool onlyTrackedBranches)
55+
public IEnumerable<Branch> GetBranchesContainingCommit([NotNull] Commit commit, IList<Branch> branches, bool onlyTrackedBranches)
5756
{
5857
if (commit == null)
5958
{
6059
throw new ArgumentNullException("commit");
6160
}
62-
Logger.WriteDebug("Heh");
61+
6362
using (Logger.IndentLog(string.Format("Getting branches containing the commit '{0}'.", commit.Id)))
6463
{
6564
var directBranchHasBeenFound = false;
@@ -87,7 +86,7 @@ public IEnumerable<Branch> GetBranchesContainingCommit([NotNull] Commit commit,
8786
{
8887
Logger.WriteInfo(string.Format("Searching for commits reachable from '{0}'.", branch.FriendlyName));
8988

90-
var commits = repository.Commits.QueryBy(new CommitFilter
89+
var commits = this.Repository.Commits.QueryBy(new CommitFilter
9190
{
9291
IncludeReachableFrom = branch
9392
}).Where(c => c.Sha == commit.Sha);
@@ -107,7 +106,7 @@ public IEnumerable<Branch> GetBranchesContainingCommit([NotNull] Commit commit,
107106
/// <summary>
108107
/// Find the merge base of the two branches, i.e. the best common ancestor of the two branches' tips.
109108
/// </summary>
110-
public Commit FindMergeBase(Branch branch, Branch otherBranch, IRepository repository)
109+
public Commit FindMergeBase(Branch branch, Branch otherBranch)
111110
{
112111
var key = Tuple.Create(branch, otherBranch);
113112

@@ -129,7 +128,7 @@ public Commit FindMergeBase(Branch branch, Branch otherBranch, IRepository repos
129128
commitToFindCommonBase = otherBranch.Tip.Parents.First();
130129
}
131130

132-
var findMergeBase = repository.ObjectDatabase.FindMergeBase(commit, commitToFindCommonBase);
131+
var findMergeBase = this.Repository.ObjectDatabase.FindMergeBase(commit, commitToFindCommonBase);
133132
if (findMergeBase != null)
134133
{
135134
Logger.WriteInfo(string.Format("Found merge base of {0}", findMergeBase.Sha));
@@ -145,7 +144,7 @@ public Commit FindMergeBase(Branch branch, Branch otherBranch, IRepository repos
145144
if (mergeBaseWasForwardMerge)
146145
{
147146
var second = commitToFindCommonBase.Parents.First();
148-
var mergeBase = repository.ObjectDatabase.FindMergeBase(commit, second);
147+
var mergeBase = this.Repository.ObjectDatabase.FindMergeBase(commit, second);
149148
if (mergeBase == findMergeBase)
150149
{
151150
break;
@@ -157,7 +156,7 @@ public Commit FindMergeBase(Branch branch, Branch otherBranch, IRepository repos
157156
}
158157

159158
// Store in cache.
160-
mergeBaseCache.Add(key, new MergeBaseData(branch, otherBranch, repository, findMergeBase));
159+
mergeBaseCache.Add(key, new MergeBaseData(branch, otherBranch, this.Repository, findMergeBase));
161160

162161
return findMergeBase;
163162
}
@@ -167,7 +166,7 @@ public Commit FindMergeBase(Branch branch, Branch otherBranch, IRepository repos
167166
/// Find the commit where the given branch was branched from another branch.
168167
/// If there are multiple such commits and branches, returns the newest commit.
169168
/// </summary>
170-
public BranchCommit FindCommitBranchWasBranchedFrom([NotNull] Branch branch, IRepository repository, params Branch[] excludedBranches)
169+
public BranchCommit FindCommitBranchWasBranchedFrom([NotNull] Branch branch, params Branch[] excludedBranches)
171170
{
172171
if (branch == null)
173172
{
@@ -186,7 +185,6 @@ public BranchCommit FindCommitBranchWasBranchedFrom([NotNull] Branch branch, IRe
186185
}
187186
}
188187

189-
190188
List<BranchCommit> GetMergeCommitsForBranch(Branch branch)
191189
{
192190
if (mergeBaseCommitsCache.ContainsKey(branch))
@@ -197,15 +195,15 @@ List<BranchCommit> GetMergeCommitsForBranch(Branch branch)
197195
return mergeBaseCommitsCache[branch];
198196
}
199197

200-
var branchMergeBases = repository.Branches.Select(otherBranch =>
198+
var branchMergeBases = Repository.Branches.Select(otherBranch =>
201199
{
202200
if (otherBranch.Tip == null)
203201
{
204202
Logger.WriteWarning(string.Format(missingTipFormat, otherBranch.FriendlyName));
205203
return BranchCommit.Empty;
206204
}
207205

208-
var findMergeBase = FindMergeBase(branch, otherBranch, repository);
206+
var findMergeBase = FindMergeBase(branch, otherBranch);
209207
return new BranchCommit(findMergeBase, otherBranch);
210208
}).Where(b => b.Commit != null).OrderByDescending(b => b.Commit.Committer.When).ToList();
211209
mergeBaseCommitsCache.Add(branch, branchMergeBases);

src/GitVersionCore/GitVersionContext.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public GitVersionContext(IRepository repository, Config configuration, bool isFo
1717
public GitVersionContext(IRepository repository, Branch currentBranch, Config configuration, bool onlyEvaluateTrackedBranches = true, string commitId = null)
1818
{
1919
Repository = repository;
20-
RepostioryMetadataProvider = new GitRepoMetadataProvider(repository);
20+
RepositoryMetadataProvider = new GitRepoMetadataProvider(repository);
2121
FullConfiguration = configuration;
2222
OnlyEvaluateTrackedBranches = onlyEvaluateTrackedBranches;
2323

@@ -47,7 +47,7 @@ public GitVersionContext(IRepository repository, Branch currentBranch, Config co
4747

4848
if (currentBranch.IsDetachedHead())
4949
{
50-
CurrentBranch = RepostioryMetadataProvider.GetBranchesContainingCommit(CurrentCommit, repository, repository.Branches.ToList(), OnlyEvaluateTrackedBranches).OnlyOrDefault() ?? currentBranch;
50+
CurrentBranch = RepositoryMetadataProvider.GetBranchesContainingCommit(CurrentCommit, repository.Branches.ToList(), OnlyEvaluateTrackedBranches).OnlyOrDefault() ?? currentBranch;
5151
}
5252
else
5353
{
@@ -79,7 +79,7 @@ public GitVersionContext(IRepository repository, Branch currentBranch, Config co
7979
public Branch CurrentBranch { get; private set; }
8080
public Commit CurrentCommit { get; private set; }
8181
public bool IsCurrentCommitTagged { get; private set; }
82-
public GitRepoMetadataProvider RepostioryMetadataProvider { get; private set; }
82+
public GitRepoMetadataProvider RepositoryMetadataProvider { get; private set; }
8383

8484
void CalculateEffectiveConfiguration()
8585
{

src/GitVersionCore/VersionCalculation/BaseVersionCalculators/VersionInBranchNameBaseVersionStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public IEnumerable<BaseVersion> GetVersions(GitVersionContext context, string ta
2525
var versionInBranch = GetVersionInBranch(branchName, tagPrefixRegex);
2626
if (versionInBranch != null)
2727
{
28-
var commitBranchWasBranchedFrom = context.RepostioryMetadataProvider.FindCommitBranchWasBranchedFrom(currentBranch, repository);
28+
var commitBranchWasBranchedFrom = context.RepositoryMetadataProvider.FindCommitBranchWasBranchedFrom(currentBranch);
2929
var branchNameOverride = branchName.RegexReplace("[-/]" + versionInBranch.Item1, string.Empty);
3030
yield return new BaseVersion(context, "Version in branch name", false, versionInBranch.Item2, commitBranchWasBranchedFrom.Commit, branchNameOverride);
3131
}

src/GitVersionCore/VersionCalculation/DevelopVersionStrategy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private IEnumerable<BaseVersion> ReleaseBranchBaseVersions(GitVersionContext con
6666
// Need to drop branch overrides and give a bit more context about
6767
// where this version came from
6868
var source1 = "Release branch exists -> " + baseVersion.Source;
69-
return new BaseVersion(context,
69+
return new BaseVersion(context,
7070
source1,
7171
baseVersion.ShouldIncrement,
7272
baseVersion.SemanticVersion,
@@ -84,7 +84,7 @@ IEnumerable<BaseVersion> GetReleaseVersion(GitVersionContext context, Branch rel
8484
var repository = context.Repository;
8585

8686
// Find the commit where the child branch was created.
87-
var baseSource = context.RepostioryMetadataProvider.FindMergeBase(releaseBranch, context.CurrentBranch, repository);
87+
var baseSource = context.RepositoryMetadataProvider.FindMergeBase(releaseBranch, context.CurrentBranch);
8888
if (baseSource == context.CurrentCommit)
8989
{
9090
// Ignore the branch if it has no commits.

src/GitVersionCore/VersionCalculation/NextVersionCalculator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ void UpdatePreReleaseTag(GitVersionContext context, SemanticVersion semanticVers
258258

259259
int? number = null;
260260

261-
var lastTag = context.RepostioryMetadataProvider
262-
.GetVersionTagsOnBranch(context.CurrentBranch, context.Repository, context.Configuration.GitTagPrefix)
261+
var lastTag = context.RepositoryMetadataProvider
262+
.GetVersionTagsOnBranch(context.CurrentBranch, context.Configuration.GitTagPrefix)
263263
.FirstOrDefault(v => v.PreReleaseTag.Name == tagToUse);
264264

265265
if (lastTag != null &&

0 commit comments

Comments
 (0)