Skip to content

Commit

Permalink
Merge remote-tracking branch 'GeirGrusom/bugfix/issue-406'
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeGinnivan committed Apr 6, 2015
2 parents 3049e66 + a0f8e39 commit fe1063f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
1 change: 1 addition & 0 deletions GitVersionTask.Tests/GitVersionTask.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
<Compile Include="Helpers\Lg2sHelperBase.cs" />
<Compile Include="UpdateAssemblyInfoTests.cs" />
<Compile Include="ModuleInitializer.cs" />
<Compile Include="WriteVersionInfoToBuildLogTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
Expand Down
22 changes: 22 additions & 0 deletions GitVersionTask.Tests/WriteVersionInfoToBuildLogTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

namespace GitVersionTask.Tests
{
using System.IO;
using NUnit.Framework;

[TestFixture]
public class WriteVersionInfoToBuildLogTests
{
[Test]
public void UsingInvalidGitDirectory_ThrowsDirectoryNotFoundException()
{
var task = new WriteVersionInfoToBuildLog
{
BuildEngine = new MockBuildEngine(),
SolutionDirectory = Path.GetTempPath()
};

Assert.That(task.InnerExecute, Throws.InstanceOf<DirectoryNotFoundException>());
}
}
}
13 changes: 9 additions & 4 deletions GitVersionTask/WriteVersionInfoToBuildLog.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
namespace GitVersionTask
{
using System;
using System.Collections.Generic;
using GitVersion;
using GitVersion.Helpers;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using System;
using System.Collections.Generic;
using System.IO;
using Logger = GitVersion.Logger;

public class WriteVersionInfoToBuildLog : Task
Expand Down Expand Up @@ -53,6 +54,10 @@ public void InnerExecute()
{
Tuple<CachedVersion, GitVersionContext> result;
var gitDirectory = GitDirFinder.TreeWalkForDotGitDir(SolutionDirectory);

if (gitDirectory == null)
throw new DirectoryNotFoundException(string.Format("Unable to locate a git repository in \"{0}\". Make sure that the solution is located in a git controlled folder. If you are using continous integration make sure that the sources are checked out on the build agent.", SolutionDirectory));

var configuration = ConfigurationProvider.Provide(gitDirectory, fileSystem);
if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out result, configuration, NoFetch))
{
Expand All @@ -68,8 +73,8 @@ public void InnerExecute()
var versioningMode = config.VersioningMode;

var variablesFor = VariableProvider.GetVariablesFor(
cachedVersion.SemanticVersion, assemblyVersioningScheme, versioningMode,
config.ContinuousDeploymentFallbackTag,
cachedVersion.SemanticVersion, assemblyVersioningScheme, versioningMode,
config.ContinuousDeploymentFallbackTag,
gitVersionContext.IsCurrentCommitTagged);
WriteIntegrationParameters(cachedVersion, BuildServerList.GetApplicableBuildServers(authentication), variablesFor);
}
Expand Down

0 comments on commit fe1063f

Please sign in to comment.