Skip to content

Commit

Permalink
Align naming: renamed isForTrackedBranchOnly and onlyEvaluateTrackedB…
Browse files Browse the repository at this point in the history
…ranches to onlyTrackedBranches
  • Loading branch information
crazycrank committed Jan 19, 2020
1 parent e03b27b commit 54baccd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions src/GitVersionCore.Tests/GitToolsTestingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static class GitToolsTestingExtensions

static GitToolsTestingExtensions() => sp = ConfigureService();

public static VersionVariables GetVersion(this RepositoryFixtureBase fixture, Config configuration = null, IRepository repository = null, string commitId = null, bool isForTrackedBranchOnly = true, string targetBranch = null)
public static VersionVariables GetVersion(this RepositoryFixtureBase fixture, Config configuration = null, IRepository repository = null, string commitId = null, bool onlyTrackedBranches = true, string targetBranch = null)
{
if (configuration == null)
{
Expand All @@ -31,7 +31,7 @@ public static VersionVariables GetVersion(this RepositoryFixtureBase fixture, Co
var variableProvider = sp.GetService<IVariableProvider>();
var versionFinder = sp.GetService<IGitVersionFinder>();

var gitVersionContext = new GitVersionContext(repository ?? fixture.Repository, log, targetBranch, configuration, isForTrackedBranchOnly, commitId);
var gitVersionContext = new GitVersionContext(repository ?? fixture.Repository, log, targetBranch, configuration, onlyTrackedBranches, commitId);
var executeGitVersion = versionFinder.FindVersion(gitVersionContext);
var variables = variableProvider.GetVariablesFor(executeGitVersion, gitVersionContext.Configuration, gitVersionContext.IsCurrentCommitTagged);

Expand All @@ -47,19 +47,19 @@ public static VersionVariables GetVersion(this RepositoryFixtureBase fixture, Co
}
}

public static void AssertFullSemver(this RepositoryFixtureBase fixture, string fullSemver, IRepository repository = null, string commitId = null, bool isForTrackedBranchOnly = true, string targetBranch = null)
public static void AssertFullSemver(this RepositoryFixtureBase fixture, string fullSemver, IRepository repository = null, string commitId = null, bool onlyTrackedBranches = true, string targetBranch = null)
{
fixture.AssertFullSemver(new Config(), fullSemver, repository, commitId, isForTrackedBranchOnly, targetBranch);
fixture.AssertFullSemver(new Config(), fullSemver, repository, commitId, onlyTrackedBranches, targetBranch);
}

public static void AssertFullSemver(this RepositoryFixtureBase fixture, Config configuration, string fullSemver, IRepository repository = null, string commitId = null, bool isForTrackedBranchOnly = true, string targetBranch = null)
public static void AssertFullSemver(this RepositoryFixtureBase fixture, Config configuration, string fullSemver, IRepository repository = null, string commitId = null, bool onlyTrackedBranches = true, string targetBranch = null)
{
configuration.Reset();
Console.WriteLine("---------");

try
{
var variables = fixture.GetVersion(configuration, repository, commitId, isForTrackedBranchOnly, targetBranch);
var variables = fixture.GetVersion(configuration, repository, commitId, onlyTrackedBranches, targetBranch);
variables.FullSemVer.ShouldBe(fullSemver);
}
catch (Exception)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void WhenDevelopBranchedFromMasterDetachedHeadMinorIsIncreased()
var commit = fixture.Repository.Head.Tip;
fixture.Repository.MakeACommit();
Commands.Checkout(fixture.Repository, commit);
fixture.AssertFullSemver("1.1.0-alpha.1", isForTrackedBranchOnly: false);
fixture.AssertFullSemver("1.1.0-alpha.1", onlyTrackedBranches: false);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void GivenARepositoryWithCommitsButNoTagsWithDetachedHeadVersionShouldBe0
Commands.Checkout(fixture.Repository, commit);

// When
fixture.AssertFullSemver("0.1.0+2", isForTrackedBranchOnly: false);
fixture.AssertFullSemver("0.1.0+2", onlyTrackedBranches: false);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void GivenARemoteGitRepositoryWhenCheckingOutDetachedheadUsingExistingImp
fixture.LocalRepositoryFixture.Repository,
fixture.LocalRepositoryFixture.Repository.Head.Tip);

Should.Throw<WarningException>(() => fixture.AssertFullSemver("0.1.0+4", fixture.LocalRepositoryFixture.Repository, isForTrackedBranchOnly: false),
Should.Throw<WarningException>(() => fixture.AssertFullSemver("0.1.0+4", fixture.LocalRepositoryFixture.Repository, onlyTrackedBranches: false),
$"It looks like the branch being examined is a detached Head pointing to commit '{fixture.LocalRepositoryFixture.Repository.Head.Tip.Id.ToString(7)}'. Without a proper branch name GitVersion cannot determine the build version.");
}

Expand Down
12 changes: 6 additions & 6 deletions src/GitVersionCore/GitVersionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ public class GitVersionContext
{
private readonly ILog log;

public GitVersionContext(IRepository repository, ILog log, string targetBranch, Config configuration, bool onlyEvaluateTrackedBranches = false, string commitId = null)
: this(repository, log, GetTargetBranch(repository, targetBranch), configuration, onlyEvaluateTrackedBranches, commitId)
public GitVersionContext(IRepository repository, ILog log, string targetBranch, Config configuration, bool onlyTrackedBranches = false, string commitId = null)
: this(repository, log, GetTargetBranch(repository, targetBranch), configuration, onlyTrackedBranches, commitId)
{
}

public GitVersionContext(IRepository repository, ILog log, Branch currentBranch, Config configuration, bool onlyEvaluateTrackedBranches = false, string commitId = null)
public GitVersionContext(IRepository repository, ILog log, Branch currentBranch, Config configuration, bool onlyTrackedBranches = false, string commitId = null)
{
this.log = log;
Repository = repository;
RepositoryMetadataProvider = new GitRepoMetadataProvider(repository, log, configuration);
FullConfiguration = configuration;
OnlyEvaluateTrackedBranches = onlyEvaluateTrackedBranches;
OnlyTrackedBranches = onlyTrackedBranches;

if (currentBranch == null)
throw new InvalidOperationException("Need a branch to operate on");
Expand Down Expand Up @@ -53,7 +53,7 @@ public GitVersionContext(IRepository repository, ILog log, Branch currentBranch,

if (currentBranch.IsDetachedHead())
{
CurrentBranch = RepositoryMetadataProvider.GetBranchesContainingCommit(CurrentCommit, repository.Branches.ToList(), OnlyEvaluateTrackedBranches).OnlyOrDefault() ?? currentBranch;
CurrentBranch = RepositoryMetadataProvider.GetBranchesContainingCommit(CurrentCommit, repository.Branches.ToList(), OnlyTrackedBranches).OnlyOrDefault() ?? currentBranch;
}
else
{
Expand All @@ -78,7 +78,7 @@ public GitVersionContext(IRepository repository, ILog log, Branch currentBranch,
/// </summary>
public Config FullConfiguration { get; }
public SemanticVersion CurrentCommitTaggedVersion { get; }
public bool OnlyEvaluateTrackedBranches { get; }
public bool OnlyTrackedBranches { get; }
public EffectiveConfiguration Configuration { get; private set; }
public IRepository Repository { get; }
public Branch CurrentBranch { get; }
Expand Down

0 comments on commit 54baccd

Please sign in to comment.