我正在定制我们的构建活动。我想请你帮忙解决一个问题。
以下是我们的版本控制层次结构。
Main
|- Dev
|- QA
我们正在开发 Dev 分支,在进行构建时,我们需要将 Dev 分支合并到 Main,然后再合并到 QA。Main 是您可能知道的根分支。
在我们的构建模板中,我添加了两个自定义活动来将一个从 Dev 合并到 Main,另一个从 Main 合并到 QA。以下是自定义活动的代码。
protected override string Execute(CodeActivityContext context)
{
string lstrStatus = string.Empty;
string lstrSourceBranchPath = context.GetValue(this.SourceBranchPath);
string lstrTargetBranchPath = context.GetValue(this.TargetBranchPath);
// Obtain the runtime value of the input arguments
Workspace workspace = context.GetValue(this.Workspace);
GetStatus status = workspace.Merge(lstrSourceBranchPath,
lstrTargetBranchPath,
null,
null,
LockLevel.None,
RecursionType.Full,
MergeOptions.None);
// resolve the conflicts, if any
if (status.NumConflicts > 0)
{
Conflict[] conflicts = workspace.QueryConflicts(new string[]
{ lstrTargetBranchPath }, true);
foreach (Conflict conflict in conflicts)
{
conflict.Resolution = Resolution.AcceptTheirs;
workspace.ResolveConflict(conflict);
}
}
// checkin the changes
PendingChange[] pendingChanges = workspace.GetPendingChanges();
if (pendingChanges != null && pendingChanges.Length > 0)
{
workspace.CheckIn(pendingChanges, "Merged by MERGE BRANCHES activity");
}
return lstrStatus;
}
问题是,合并完美地发生在服务器中。但是,它没有反映在本地文件夹中。我尝试SyncWorkspace activity
在每个Merge custom activity
. 还是行不通。