diff --git a/build-package.bat b/build-package.bat
index 5d5b8766e..051298f2a 100644
--- a/build-package.bat
+++ b/build-package.bat
@@ -1,5 +1,5 @@
@echo off
cls
-Tools\NAnt\NAnt.exe package -buildfile:ccnet.build -D:CCNetLabel=1.5.0.0 -nologo -logfile:nant-build-package.log.txt %*
+Tools\NAnt\NAnt.exe package -buildfile:ccnet.build -D:CCNetLabel=1.8.5.0 -nologo -logfile:nant-build-package.log.txt %*
echo %time% %date%
pause
\ No newline at end of file
diff --git a/project/UnitTests/Core/SourceControl/GitTest.cs b/project/UnitTests/Core/SourceControl/GitTest.cs
index 464ef75b4..ff61cafd8 100644
--- a/project/UnitTests/Core/SourceControl/GitTest.cs
+++ b/project/UnitTests/Core/SourceControl/GitTest.cs
@@ -121,6 +121,28 @@ public void PopulateFromMinimallySpecifiedXml()
Assert.AreEqual(100, git.MaxAmountOfModificationsToFetch, "#C14");
}
+ [Test]
+ public void SparseCheckOutSpeclifedXML()
+ {
+ const string xml = @"
+
+ git
+ git@git.gss.com.tw:HRSBU/HRSPD/Radar.Family/Radar2-Mtb.git
+ master
+ D:\git\working
+ true
+ MTB
+";
+
+ git = (Git)NetReflector.Read(xml);
+ Assert.AreEqual("git", git.Executable, "#B1");
+ Assert.AreEqual(@"git@git.gss.com.tw:HRSBU/HRSPD/Radar.Family/Radar2-Mtb.git", git.Repository, "#B2");
+ Assert.AreEqual("master", git.Branch, "#B3");
+ Assert.AreEqual(@"D:\git\working", git.WorkingDirectory, "#B4");
+ Assert.AreEqual(true, git.AutoGetSource, "#B5");
+ Assert.AreEqual("MTB", git.SparseCheckoutPaths[0], "#B6");
+ }
+
[Test]
public void ShouldApplyLabelIfTagOnSuccessTrue()
{
@@ -265,7 +287,21 @@ public void ShouldLogWholeHistoryIfCommitNotPresentInFromIntegrationResult()
private void ExpectToExecuteWithArgumentsAndReturn(string args, ProcessResult returnValue)
{
- mockProcessExecutor.ExpectAndReturn("Execute", returnValue, NewProcessInfo(args, DefaultWorkingDirectory));
+ var processInfo = NewProcessInfo(args, DefaultWorkingDirectory);
+ processInfo.StandardInputContent = "";
+ mockProcessExecutor.ExpectAndReturn("Execute", returnValue, processInfo);
+ }
+
+ private new void ExpectToExecuteArguments(string args)
+ {
+ ExpectToExecuteArguments(args, DefaultWorkingDirectory);
+ }
+
+ protected new void ExpectToExecuteArguments(string args, string workingDirectory)
+ {
+ ProcessInfo processInfo = NewProcessInfo(args, workingDirectory);
+ processInfo.StandardInputContent = "";
+ ExpectToExecute(processInfo);
}
[Test]
diff --git a/project/core/sourcecontrol/Git.cs b/project/core/sourcecontrol/Git.cs
index 10d53c4bb..ed16274c4 100644
--- a/project/core/sourcecontrol/Git.cs
+++ b/project/core/sourcecontrol/Git.cs
@@ -5,6 +5,7 @@
using System.Globalization;
using System.Collections.Generic;
using ThoughtWorks.CruiseControl.Remote;
+using System;
namespace ThoughtWorks.CruiseControl.Core.Sourcecontrol
{
@@ -255,6 +256,14 @@ public class Git : ProcessSourceControl
[ReflectorProperty("workingDirectory", Required = false)]
public string WorkingDirectory { get; set; }
+ ///
+ /// use SparseCheckout to checkout path
+ ///
+ /// 1.8.5
+ /// sparse-checkout path
+ [ReflectorProperty("sparseCheckoutPaths", Required = false)]
+ public string[] SparseCheckoutPaths { get; set; }
+
///
/// Initializes a new instance of the class.
///
@@ -331,8 +340,8 @@ public override void GetSource(IIntegrationResult result)
// checkout remote branch
GitCheckoutRemoteBranch(Branch, result);
- // update submodules
- if (FetchSubmodules)
+ // update submodules
+ if (FetchSubmodules)
GitUpdateSubmodules(result);
// clean up the local working copy
@@ -420,8 +429,28 @@ private RepositoryAction CreateUpateLocalRepository(IIntegrationResult result)
{
Log.Debug(string.Concat("[Git] Working directory '", workingDirectory, "' does not exist."));
- // if the working does not exist, call git clone
- GitClone(result);
+ // has SparseCheckout Path
+ if (SparseCheckoutPaths != null && SparseCheckoutPaths.Length > 0)
+ {
+ _fileSystem.CreateDirectory(workingDirectory);
+
+ //init git respository
+ GitInit(result);
+
+ //set sparseCheckout enable
+ GitSetSparseCheckout(Branch, result);
+
+ //set git remote url
+ GitSetRometeUrl(Repository, result);
+
+ //create sparse-checkout config
+ CreateSparseCheckoutConfig(gitRepositoryDirectory, SparseCheckoutPaths, result);
+ }
+ else
+ {
+ // if the working does not exist, call git clone
+ GitClone(result);
+ }
// init submodules
if (FetchSubmodules)
@@ -483,6 +512,7 @@ private ProcessInfo NewProcessInfo(string args, IIntegrationResult result, Proce
var processInfo = new ProcessInfo(Executable, args, BaseWorkingDirectory(result), priority,
successExitCodes);
//processInfo.StreamEncoding = Encoding.UTF8;
+ processInfo.StandardInputContent = "";
return processInfo;
}
@@ -631,6 +661,63 @@ private void GitFetch(IIntegrationResult result)
ProcessExecutor.ProcessOutput -= ProcessExecutor_ProcessOutput;
}
+ ///
+ /// git init
+ ///
+ ///
+ private void GitInit(IIntegrationResult result)
+ {
+ ProcessArgumentBuilder buffer = new ProcessArgumentBuilder();
+ buffer.AddArgument("init");
+ Execute(NewProcessInfo(buffer.ToString(), result));
+ }
+
+ ///
+ /// Set SparseCheckout
+ ///
+ ///
+ ///
+ private void GitSetSparseCheckout(string branchName, IIntegrationResult result)
+ {
+ ProcessArgumentBuilder buffer = new ProcessArgumentBuilder();
+ buffer.AddArgument("config");
+ buffer.AddArgument("core.sparsecheckout");
+ buffer.AddArgument("true");
+ Execute(NewProcessInfo(buffer.ToString(), result));
+ }
+
+ ///
+ /// Set git Romete Url
+ ///
+ ///
+ ///
+ private void GitSetRometeUrl(string repository, IIntegrationResult result)
+ {
+ ProcessArgumentBuilder buffer = new ProcessArgumentBuilder();
+ buffer.AddArgument("remote");
+ buffer.AddArgument("add");
+ buffer.AddArgument("-f");
+ buffer.AddArgument("origin");
+ buffer.AddArgument(repository);
+ Execute(NewProcessInfo(buffer.ToString(), result));
+ }
+
+ ///
+ /// Create SparseCheckout config file
+ ///
+ ///
+ ///
+ ///
+ private void CreateSparseCheckoutConfig(string gitRepositoryDirectory, string[] sparseCheckoutPaths, IIntegrationResult result)
+ {
+ var configDir = string.Concat(gitRepositoryDirectory, @"\info\");
+ var configFile = string.Concat(configDir, "sparse-checkout");
+ if (Directory.Exists(configDir))
+ {
+ File.WriteAllLines(configFile, sparseCheckoutPaths);
+ }
+ }
+
///
/// Checkout a remote branch with the "git checkout -q -f 'origin/branchName'" command.
///