Skip to content

Commit ca989ce

Browse files
committed
PR 37: Merge fixBuildNumber to master +semver:minor
- 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
2 parents f92438b + 73dc39e commit ca989ce

File tree

10 files changed

+80
-15
lines changed

10 files changed

+80
-15
lines changed

GitVersion.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
assembly-versioning-scheme: None
1+
assembly-versioning-scheme: MajorMinorPatch
22
mode: ContinuousDeployment
33
continuous-delivery-fallback-tag: ''
44
next-version: 2.1.0

TfsWitMigrator.Console/Program.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ static int Main(string[] args)
8080

8181
private static object RunExecuteAndReturnExitCode(RunOptions opts)
8282
{
83+
Telemetry.Current.TrackEvent("ExecuteCommand");
8384
EngineConfiguration ec;
8485
if (opts.ConfigFile == string.Empty)
8586
{
@@ -93,21 +94,25 @@ private static object RunExecuteAndReturnExitCode(RunOptions opts)
9394
}
9495
else
9596
{
97+
Trace.WriteLine("Loading Config");
9698
StreamReader sr = new StreamReader(opts.ConfigFile);
9799
string vstsbulkeditorjson = sr.ReadToEnd();
98100
sr.Close();
99101
ec = JsonConvert.DeserializeObject<EngineConfiguration>(vstsbulkeditorjson,
100102
new FieldMapConfigJsonConverter(),
101103
new ProcessorConfigJsonConverter());
102104
}
103-
105+
Trace.WriteLine("Config Loaded, creating engine");
104106
MigrationEngine me = new MigrationEngine(ec);
107+
Trace.WriteLine("Engine created, running...");
105108
me.Run();
109+
Trace.WriteLine("Run complete...");
106110
return 0;
107111
}
108112

109113
private static object RunInitAndReturnExitCode(InitOptions opts)
110114
{
115+
Telemetry.Current.TrackEvent("InitCommand");
111116
if (!File.Exists("vstsbulkeditor.json"))
112117
{
113118
string json = JsonConvert.SerializeObject(EngineConfiguration.GetDefault(),

TfsWitMigrator.Console/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0.0")]
35+
[assembly: AssemblyVersion("0.0.0.0")]
36+
[assembly: AssemblyFileVersion("0.0.0.0")]

TfsWitMigrator.Core/Configuration/EngineConfiguration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public static EngineConfiguration GetDefault()
2727
ec.Target = new TeamProjectConfig() { Name = "DemoProjt", Collection = new Uri("https://sdd2016.visualstudio.com/") };
2828
ec.ReflectedWorkItemIDFieldName = "TfsMigrationTool.ReflectedWorkItemId";
2929
ec.FieldMaps = new List<IFieldMapConfig>();
30+
ec.FieldMaps.Add(new FieldBlankMapConfig() { WorkItemTypeName = "*", targetField = "TfsMigrationTool.ReflectedWorkItemId" });
3031
ec.FieldMaps.Add(new FieldValueMapConfig()
3132
{
3233
WorkItemTypeName = "*",
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using VSTS.DataBulkEditor.Engine.ComponentContext;
7+
8+
namespace VSTS.DataBulkEditor.Engine.Configuration.FieldMap
9+
{
10+
public class FieldBlankMapConfig : IFieldMapConfig
11+
{
12+
public string WorkItemTypeName { get; set; }
13+
public string targetField { get; set; }
14+
public Type FieldMap
15+
{
16+
get
17+
{
18+
return typeof(FieldBlankMap);
19+
}
20+
}
21+
}
22+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Microsoft.TeamFoundation.WorkItemTracking.Client;
7+
using System.Diagnostics;
8+
using VSTS.DataBulkEditor.Engine.Configuration.FieldMap;
9+
10+
namespace VSTS.DataBulkEditor.Engine.ComponentContext
11+
{
12+
public class FieldBlankMap : FieldMapBase
13+
{
14+
private FieldBlankMapConfig config;
15+
16+
public FieldBlankMap(FieldBlankMapConfig config)
17+
{
18+
this.config = config;
19+
}
20+
21+
internal override void InternalExecute(WorkItem source, WorkItem target)
22+
{
23+
if (target.Fields.Contains(config.targetField))
24+
{
25+
target.Fields[config.targetField].Value = "";
26+
Trace.WriteLine(string.Format(" [UPDATE] field mapped {0}:{1} to {2} blanked", source.Id, target.Id, this.config.targetField));
27+
}
28+
}
29+
}
30+
}

TfsWitMigrator.Core/Execution/FieldMaps/FieldToFieldMap.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ namespace VSTS.DataBulkEditor.Engine.ComponentContext
1212
public class FieldToFieldMap : FieldMapBase
1313
{
1414
private FieldtoFieldMapConfig config;
15-
private string targetField;
1615

1716
public FieldToFieldMap(FieldtoFieldMapConfig config)
1817
{
@@ -21,10 +20,10 @@ public FieldToFieldMap(FieldtoFieldMapConfig config)
2120

2221
internal override void InternalExecute(WorkItem source, WorkItem target)
2322
{
24-
if (source.Fields.Contains(config.sourceField) && target.Fields.Contains(targetField))
23+
if (source.Fields.Contains(config.sourceField) && target.Fields.Contains(config.targetField))
2524
{
26-
target.Fields[targetField].Value = source.Fields[config.sourceField].Value;
27-
Trace.WriteLine(string.Format(" [UPDATE] field mapped {0}:{1} to {2}:{3}", source.Id, config.sourceField, target.Id, targetField));
25+
target.Fields[config.targetField].Value = source.Fields[config.sourceField].Value;
26+
Trace.WriteLine(string.Format(" [UPDATE] field mapped {0}:{1} to {2}:{3}", source.Id, config.sourceField, target.Id, config.targetField));
2827
}
2928
}
3029
}

TfsWitMigrator.Core/Execution/FieldMaps/FieldToTagFieldMap.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ namespace VSTS.DataBulkEditor.Engine
1111
public class FieldToTagFieldMap : IFieldMap
1212
{
1313
private FieldtoTagMapConfig config;
14-
private string sourceField;
1514

1615
public FieldToTagFieldMap(FieldtoTagMapConfig config)
1716
{
@@ -20,13 +19,13 @@ public FieldToTagFieldMap(FieldtoTagMapConfig config)
2019

2120
public void Execute(WorkItem source, WorkItem target)
2221
{
23-
if (source.Fields.Contains(sourceField))
22+
if (source.Fields.Contains(this.config.sourceField))
2423
{
2524
List<string> newTags = target.Tags.Split(char.Parse(@";")).ToList();
2625
// to tag
27-
if (source.Fields[sourceField].Value != null)
26+
if (source.Fields[this.config.sourceField].Value != null)
2827
{
29-
string value = source.Fields[sourceField].Value.ToString();
28+
string value = source.Fields[this.config.sourceField].Value.ToString();
3029
if (string.IsNullOrEmpty(config.formatExpression))
3130
{
3231
newTags.Add(value);
@@ -37,7 +36,7 @@ public void Execute(WorkItem source, WorkItem target)
3736
}
3837

3938
target.Tags = string.Join(";", newTags.ToArray());
40-
Trace.WriteLine(string.Format(" [UPDATE] field tagged {0}:{1} to {2}:Tag with foramt of {3}", source.Id, sourceField, target.Id, config.formatExpression));
39+
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));
4140
}
4241

4342
}

TfsWitMigrator.Core/MigrationEngine.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,14 @@ public MigrationEngine(EngineConfiguration config)
3535
private void ProcessConfiguration(EngineConfiguration config)
3636
{
3737
Telemetry.EnableTrace = config.TelemetryEnableTrace;
38-
this.SetSource(new TeamProjectContext(config.Source.Collection, config.Source.Name));
39-
this.SetTarget(new TeamProjectContext(config.Target.Collection, config.Target.Name));
38+
if (config.Source != null)
39+
{
40+
this.SetSource(new TeamProjectContext(config.Source.Collection, config.Source.Name));
41+
}
42+
if (config.Target != null)
43+
{
44+
this.SetTarget(new TeamProjectContext(config.Target.Collection, config.Target.Name));
45+
}
4046
this.SetReflectedWorkItemIdFieldName(config.ReflectedWorkItemIDFieldName);
4147
if (config.FieldMaps != null)
4248
{
@@ -100,6 +106,7 @@ public ProcessingStatus Run()
100106
Stopwatch engineTimer = new Stopwatch();
101107
engineTimer.Start();
102108
ProcessingStatus ps = ProcessingStatus.Complete;
109+
Trace.WriteLine("Beginning run of {0} processors", processors.Count.ToString());
103110
foreach (ITfsProcessingContext process in processors)
104111
{
105112
Stopwatch processorTimer = new Stopwatch();

TfsWitMigrator.Core/_VSTS.DataBulkEditor.Engine.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@
253253
<ItemGroup>
254254
<Compile Include="Configuration\EngineConfiguration.cs" />
255255
<Compile Include="Configuration\FieldMap\FieldMapConfigJsonConverter.cs" />
256+
<Compile Include="Configuration\FieldMap\FieldBlankMapConfig.cs" />
256257
<Compile Include="Configuration\FieldMap\TreeToTagMapConfig.cs" />
257258
<Compile Include="Configuration\FieldMap\FieldMergeMapConfig.cs" />
258259
<Compile Include="Configuration\FieldMap\RegexFieldMapConfig.cs" />
@@ -282,6 +283,7 @@
282283
<Compile Include="Configuration\TeamProjectConfig.cs" />
283284
<Compile Include="Execution\FieldMaps\FieldMapBase.cs" />
284285
<Compile Include="Execution\FieldMaps\FieldMergeMap.cs" />
286+
<Compile Include="Execution\FieldMaps\FieldBlankMap.cs" />
285287
<Compile Include="Execution\FieldMaps\FieldToFieldMap.cs" />
286288
<Compile Include="Execution\FieldMaps\FieldValueMap.cs" />
287289
<Compile Include="Execution\FieldMaps\IFieldMap.cs" />

0 commit comments

Comments
 (0)