Skip to content

Commit

Permalink
- add ConsoleOut to GitClient
Browse files Browse the repository at this point in the history
  • Loading branch information
paul.welter committed Jun 11, 2014
1 parent 837efe9 commit ca3a380
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Source/GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18408
// Runtime Version:4.0.30319.18444
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
Expand All @@ -11,7 +11,7 @@
[assembly: System.Reflection.AssemblyCompany("https://github.com/loresoft/msbuildtasks/")]
[assembly: System.Reflection.AssemblyProduct("MSBuild.Community.Tasks")]
[assembly: System.Reflection.AssemblyCopyright("Copyright © 2014 MSBuild Community Tasks Project")]
[assembly: System.Reflection.AssemblyConfiguration("Commit 38413f3")]
[assembly: System.Reflection.AssemblyConfiguration("Commit 837efe9")]
[assembly: System.Runtime.InteropServices.ComVisible(false)]
[assembly: System.CLSCompliant(false)]
[assembly: System.Reflection.AssemblyVersion("1.4.0.0")]
Expand All @@ -28,7 +28,7 @@ internal sealed partial class ThisAssembly {

internal const string AssemblyCopyright = "Copyright © 2014 MSBuild Community Tasks Project";

internal const string AssemblyConfiguration = "Commit 38413f3";
internal const string AssemblyConfiguration = "Commit 837efe9";

internal const string AssemblyVersion = "1.4.0.0";

Expand Down
33 changes: 33 additions & 0 deletions Source/MSBuild.Community.Tasks.Tests/Git/GitClientTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.IO;
using MSBuild.Community.Tasks.Git;
using NUnit.Framework;

namespace MSBuild.Community.Tasks.Tests.Git
{
[TestFixture]
public class GitClientTest
{
[Test]
public void Execute()
{
var task = new GitClient();
task.BuildEngine = new MockBuild();
task.ToolPath = @"C:\Program Files (x86)\Git\bin";


string prjRootPath = TaskUtility.GetProjectRootDirectory(true);
task.LocalPath = Path.Combine(prjRootPath, @"Source");

task.Command = "symbolic-ref";
task.Arguments = "HEAD";

bool result = task.Execute();

Assert.IsTrue(result, "Execute Failed");

Assert.IsTrue(task.ConsoleOutput.Length > 0);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<Compile Include="Fusion\FusionWrapperTest.cs" />
<Compile Include="FxCopTest.cs" />
<Compile Include="GacUtilTest.cs" />
<Compile Include="Git\GitClientTest.cs" />
<Compile Include="Git\GitDescribeTest.cs" />
<Compile Include="Git\GitBranchTest.cs" />
<Compile Include="Git\GitCommitsTest.cs" />
Expand Down
32 changes: 28 additions & 4 deletions Source/MSBuild.Community.Tasks/Git/GitClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ namespace MSBuild.Community.Tasks.Git
public class GitClient : ToolTask
{
private string _initialToolPath;

private readonly List<ITaskItem> _consoleOut;
/// <summary>
/// Default constructor. Creates a new GitClient task.
/// </summary>
public GitClient()
{
_consoleOut = new List<ITaskItem>();
_initialToolPath = ToolPath;
}

Expand All @@ -62,12 +63,21 @@ public GitClient()
/// </summary>
public string Arguments { get; set; }


/// <summary>
/// Gets or sets the local or working path for git command.
/// </summary>
public string LocalPath { get; set; }


/// <summary>
/// Gets command console output messages.
/// </summary>
[Output]
public ITaskItem[] ConsoleOutput
{
get { return _consoleOut.ToArray(); }
set { }
}

private string FindToolPath(string toolName)
{
string toolPath =
Expand Down Expand Up @@ -170,7 +180,7 @@ protected override string ToolName
{
get { return ToolPathUtil.MakeToolName("git"); }
}

/// <summary>
/// Indicates whether all task paratmeters are valid.
/// </summary>
Expand Down Expand Up @@ -200,5 +210,19 @@ protected override string GetWorkingDirectory()

return LocalPath;
}

/// <summary>
/// Parses a single line of text to identify any errors or warnings in canonical format.
/// </summary>
/// <param name="singleLine">A single line of text for the method to parse.</param>
/// <param name="messageImportance">A value of <see cref="T:Microsoft.Build.Framework.MessageImportance"/> that indicates the importance level with which to log the message.</param>
protected override void LogEventsFromTextOutput(string singleLine, MessageImportance messageImportance)
{
base.LogEventsFromTextOutput(singleLine, messageImportance);

var messageItem = new TaskItem(singleLine);
_consoleOut.Add(messageItem);
}

}
}

0 comments on commit ca3a380

Please sign in to comment.