Skip to content

Commit

Permalink
PR 37: Merge fixBuildNumber to master +semver:minor
Browse files Browse the repository at this point in the history
 - Updated to use full build number +semver:patch
 - Merge branch 'master'
 - Fixed build number and added more trace to detect user erros
 - Updated to add new blanking field
  • Loading branch information
MrHinsh committed Aug 16, 2016
2 parents f92438b + 73dc39e commit ca989ce
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 15 deletions.
2 changes: 1 addition & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
assembly-versioning-scheme: None
assembly-versioning-scheme: MajorMinorPatch
mode: ContinuousDeployment
continuous-delivery-fallback-tag: ''
next-version: 2.1.0
Expand Down
7 changes: 6 additions & 1 deletion TfsWitMigrator.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ static int Main(string[] args)

private static object RunExecuteAndReturnExitCode(RunOptions opts)
{
Telemetry.Current.TrackEvent("ExecuteCommand");
EngineConfiguration ec;
if (opts.ConfigFile == string.Empty)
{
Expand All @@ -93,21 +94,25 @@ private static object RunExecuteAndReturnExitCode(RunOptions opts)
}
else
{
Trace.WriteLine("Loading Config");
StreamReader sr = new StreamReader(opts.ConfigFile);
string vstsbulkeditorjson = sr.ReadToEnd();
sr.Close();
ec = JsonConvert.DeserializeObject<EngineConfiguration>(vstsbulkeditorjson,
new FieldMapConfigJsonConverter(),
new ProcessorConfigJsonConverter());
}

Trace.WriteLine("Config Loaded, creating engine");
MigrationEngine me = new MigrationEngine(ec);
Trace.WriteLine("Engine created, running...");
me.Run();
Trace.WriteLine("Run complete...");
return 0;
}

private static object RunInitAndReturnExitCode(InitOptions opts)
{
Telemetry.Current.TrackEvent("InitCommand");
if (!File.Exists("vstsbulkeditor.json"))
{
string json = JsonConvert.SerializeObject(EngineConfiguration.GetDefault(),
Expand Down
4 changes: 2 additions & 2 deletions TfsWitMigrator.Console/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyFileVersion("0.0.0.0")]
1 change: 1 addition & 0 deletions TfsWitMigrator.Core/Configuration/EngineConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static EngineConfiguration GetDefault()
ec.Target = new TeamProjectConfig() { Name = "DemoProjt", Collection = new Uri("https://sdd2016.visualstudio.com/") };
ec.ReflectedWorkItemIDFieldName = "TfsMigrationTool.ReflectedWorkItemId";
ec.FieldMaps = new List<IFieldMapConfig>();
ec.FieldMaps.Add(new FieldBlankMapConfig() { WorkItemTypeName = "*", targetField = "TfsMigrationTool.ReflectedWorkItemId" });
ec.FieldMaps.Add(new FieldValueMapConfig()
{
WorkItemTypeName = "*",
Expand Down
22 changes: 22 additions & 0 deletions TfsWitMigrator.Core/Configuration/FieldMap/FieldBlankMapConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VSTS.DataBulkEditor.Engine.ComponentContext;

namespace VSTS.DataBulkEditor.Engine.Configuration.FieldMap
{
public class FieldBlankMapConfig : IFieldMapConfig
{
public string WorkItemTypeName { get; set; }
public string targetField { get; set; }
public Type FieldMap
{
get
{
return typeof(FieldBlankMap);
}
}
}
}
30 changes: 30 additions & 0 deletions TfsWitMigrator.Core/Execution/FieldMaps/FieldBlankMap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using System.Diagnostics;
using VSTS.DataBulkEditor.Engine.Configuration.FieldMap;

namespace VSTS.DataBulkEditor.Engine.ComponentContext
{
public class FieldBlankMap : FieldMapBase
{
private FieldBlankMapConfig config;

public FieldBlankMap(FieldBlankMapConfig config)
{
this.config = config;
}

internal override void InternalExecute(WorkItem source, WorkItem target)
{
if (target.Fields.Contains(config.targetField))
{
target.Fields[config.targetField].Value = "";
Trace.WriteLine(string.Format(" [UPDATE] field mapped {0}:{1} to {2} blanked", source.Id, target.Id, this.config.targetField));
}
}
}
}
7 changes: 3 additions & 4 deletions TfsWitMigrator.Core/Execution/FieldMaps/FieldToFieldMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace VSTS.DataBulkEditor.Engine.ComponentContext
public class FieldToFieldMap : FieldMapBase
{
private FieldtoFieldMapConfig config;
private string targetField;

public FieldToFieldMap(FieldtoFieldMapConfig config)
{
Expand All @@ -21,10 +20,10 @@ public FieldToFieldMap(FieldtoFieldMapConfig config)

internal override void InternalExecute(WorkItem source, WorkItem target)
{
if (source.Fields.Contains(config.sourceField) && target.Fields.Contains(targetField))
if (source.Fields.Contains(config.sourceField) && target.Fields.Contains(config.targetField))
{
target.Fields[targetField].Value = source.Fields[config.sourceField].Value;
Trace.WriteLine(string.Format(" [UPDATE] field mapped {0}:{1} to {2}:{3}", source.Id, config.sourceField, target.Id, targetField));
target.Fields[config.targetField].Value = source.Fields[config.sourceField].Value;
Trace.WriteLine(string.Format(" [UPDATE] field mapped {0}:{1} to {2}:{3}", source.Id, config.sourceField, target.Id, config.targetField));
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions TfsWitMigrator.Core/Execution/FieldMaps/FieldToTagFieldMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace VSTS.DataBulkEditor.Engine
public class FieldToTagFieldMap : IFieldMap
{
private FieldtoTagMapConfig config;
private string sourceField;

public FieldToTagFieldMap(FieldtoTagMapConfig config)
{
Expand All @@ -20,13 +19,13 @@ public FieldToTagFieldMap(FieldtoTagMapConfig config)

public void Execute(WorkItem source, WorkItem target)
{
if (source.Fields.Contains(sourceField))
if (source.Fields.Contains(this.config.sourceField))
{
List<string> newTags = target.Tags.Split(char.Parse(@";")).ToList();
// to tag
if (source.Fields[sourceField].Value != null)
if (source.Fields[this.config.sourceField].Value != null)
{
string value = source.Fields[sourceField].Value.ToString();
string value = source.Fields[this.config.sourceField].Value.ToString();
if (string.IsNullOrEmpty(config.formatExpression))
{
newTags.Add(value);
Expand All @@ -37,7 +36,7 @@ public void Execute(WorkItem source, WorkItem target)
}

target.Tags = string.Join(";", newTags.ToArray());
Trace.WriteLine(string.Format(" [UPDATE] field tagged {0}:{1} to {2}:Tag with foramt of {3}", source.Id, sourceField, target.Id, config.formatExpression));
Trace.WriteLine(string.Format(" [UPDATE] field tagged {0}:{1} to {2}:Tag with foramt of {3}", source.Id, this.config.sourceField, target.Id, config.formatExpression));
}

}
Expand Down
11 changes: 9 additions & 2 deletions TfsWitMigrator.Core/MigrationEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ public MigrationEngine(EngineConfiguration config)
private void ProcessConfiguration(EngineConfiguration config)
{
Telemetry.EnableTrace = config.TelemetryEnableTrace;
this.SetSource(new TeamProjectContext(config.Source.Collection, config.Source.Name));
this.SetTarget(new TeamProjectContext(config.Target.Collection, config.Target.Name));
if (config.Source != null)
{
this.SetSource(new TeamProjectContext(config.Source.Collection, config.Source.Name));
}
if (config.Target != null)
{
this.SetTarget(new TeamProjectContext(config.Target.Collection, config.Target.Name));
}
this.SetReflectedWorkItemIdFieldName(config.ReflectedWorkItemIDFieldName);
if (config.FieldMaps != null)
{
Expand Down Expand Up @@ -100,6 +106,7 @@ public ProcessingStatus Run()
Stopwatch engineTimer = new Stopwatch();
engineTimer.Start();
ProcessingStatus ps = ProcessingStatus.Complete;
Trace.WriteLine("Beginning run of {0} processors", processors.Count.ToString());
foreach (ITfsProcessingContext process in processors)
{
Stopwatch processorTimer = new Stopwatch();
Expand Down
2 changes: 2 additions & 0 deletions TfsWitMigrator.Core/_VSTS.DataBulkEditor.Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@
<ItemGroup>
<Compile Include="Configuration\EngineConfiguration.cs" />
<Compile Include="Configuration\FieldMap\FieldMapConfigJsonConverter.cs" />
<Compile Include="Configuration\FieldMap\FieldBlankMapConfig.cs" />
<Compile Include="Configuration\FieldMap\TreeToTagMapConfig.cs" />
<Compile Include="Configuration\FieldMap\FieldMergeMapConfig.cs" />
<Compile Include="Configuration\FieldMap\RegexFieldMapConfig.cs" />
Expand Down Expand Up @@ -282,6 +283,7 @@
<Compile Include="Configuration\TeamProjectConfig.cs" />
<Compile Include="Execution\FieldMaps\FieldMapBase.cs" />
<Compile Include="Execution\FieldMaps\FieldMergeMap.cs" />
<Compile Include="Execution\FieldMaps\FieldBlankMap.cs" />
<Compile Include="Execution\FieldMaps\FieldToFieldMap.cs" />
<Compile Include="Execution\FieldMaps\FieldValueMap.cs" />
<Compile Include="Execution\FieldMaps\IFieldMap.cs" />
Expand Down

0 comments on commit ca989ce

Please sign in to comment.