Skip to content

Commit

Permalink
Collection of Wee Changes (#2452)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHinsh authored Oct 16, 2024
2 parents 2e7fa8d + f0c32c7 commit 459d674
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@8575951200e472d5f2d95c625da0c7bec8217c42 # v1.161.0
uses: ruby/setup-ruby@v1 # v1.161.0
with:
ruby-version: '3.2' # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
Expand Down
22 changes: 11 additions & 11 deletions docs/Reference/Generated/MigrationTools.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,6 @@ namespace MigrationTools.Host.Commands
{
internal class ExecuteMigrationCommandSettings : CommandSettingsBase
{
[Description("Domain used to connect to the source TFS instance.")]
[CommandOption("--sourceDomain")]
public string SourceDomain { get; set; }

[Description("User Name used to connect to the source TFS instance.")]
[CommandOption("--sourceUserName")]
public string SourceUserName { get; set; }

[Description("Password used to connect to source TFS instance.")]
[CommandOption("--sourcePassword")]
public string SourcePassword { get; set; }

[Description("Domain used to connect to the target TFS instance.")]
[CommandOption("--targetDomain")]
public string TargetDomain { get; set; }

[Description("User Name used to connect to the target TFS instance.")]
[CommandOption("--targetUserName")]
public string TargetUserName { get; set; }

[Description("Password used to connect to target TFS instance.")]
[CommandOption("--targetPassword")]
public string TargetPassword { get; set; }

}
}
10 changes: 5 additions & 5 deletions src/MigrationTools.Host/MigrationToolHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,18 @@ public static IHostBuilder CreateDefaultBuilder(string[] args, Action<IConfigura
{
config.AddCommand<Commands.ExecuteMigrationCommand>("execute")
.WithDescription("Executes the enables processors specified in the configuration file.")
.WithExample("execute -config \"configuration.json\"")
.WithExample("execute -config \"configuration.json\" --skipVersionCheck ");
.WithExample("execute --config \"configuration.json\"")
.WithExample("execute --config \"configuration.json\" --skipVersionCheck ");
config.AddCommand<Commands.InitMigrationCommand>("init")
.WithDescription($"Creates an default configuration file or applies templates! Available templates are `{string.Join("`, `", Enum.GetNames(typeof(OptionsConfigurationTemplate)))}`. With `Reference` loading all options with their defaults.")
.WithExample("init -template Basic");
.WithExample("init --template Basic");
config.AddCommand<Commands.UpgradeConfigCommand>("upgrade")
.WithDescription("Attempts to upgrade your config from the old version to the new one. For each option we will load the defaults, then apply your config. This will only bring across valid settings. This is 'best effort' and you will need to check all the values as we have changed a lot! Also note that it will automatically load any defaults in Environment variables which may require you to remove secrets from the output file.")
.WithExample("upgrade -config \"configuration.json\"");
.WithExample("upgrade --config \"configuration.json\"");
config.AddCommand<Commands.ConfigurationBuilderCommand>("builder")
.WithDescription("Creates or edits a configuration file")
.WithExample("builder -config \"configuration.json\"").IsHidden();
.WithExample("builder --config \"configuration.json\"").IsHidden();
extraCommands?.Invoke(config);
config.PropagateExceptions();
Expand Down
26 changes: 14 additions & 12 deletions src/MigrationTools/Tools/StringManipulatorTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class StringManipulatorTool : Tool<StringManipulatorToolOptions>, IString
{

public StringManipulatorTool(IOptions<StringManipulatorToolOptions> options, IServiceProvider services, ILogger<StringManipulatorTool> logger, ITelemetryLogger telemetryLogger)
: base(options,services, logger, telemetryLogger)
: base(options, services, logger, telemetryLogger)
{
}

Expand All @@ -39,19 +39,21 @@ public void ProcessorExecutionWithFieldItem(IProcessor processor, FieldItem fiel
AddDefaultManipulator();
}
foreach (var manipulator in Options.Manipulators)
{
if (manipulator.Enabled)
{
if (manipulator.Enabled)
{
Log.LogDebug("{WorkItemProcessorEnricher}::ProcessorExecutionWithFieldItem::Running::{Description} with {pattern}", GetType().Name, manipulator.Description, manipulator.Pattern);
fieldItem.Value = Regex.Replace((string)fieldItem.Value, manipulator.Pattern, manipulator.Replacement);

}
else
{
Log.LogDebug("{WorkItemProcessorEnricher}::ProcessorExecutionWithFieldItem::Disabled::{Description}", GetType().Name, manipulator.Description);
}
Log.LogDebug("{WorkItemProcessorEnricher}::ProcessorExecutionWithFieldItem::Running::{Description} with {pattern}", GetType().Name, manipulator.Description, manipulator.Pattern);
var originalValue = fieldItem.Value;
fieldItem.Value = Regex.Replace((string)fieldItem.Value, manipulator.Pattern, manipulator.Replacement);
Log.LogTrace("{WorkItemProcessorEnricher}::ProcessorExecutionWithFieldItem::Running::{Description}::Original::{@OriginalValue}", GetType().Name, manipulator.Description, originalValue);
Log.LogTrace("{WorkItemProcessorEnricher}::ProcessorExecutionWithFieldItem::Running::{Description}::New::{@fieldItemValue}", GetType().Name, manipulator.Description, fieldItem.Value);
}
else
{
Log.LogDebug("{WorkItemProcessorEnricher}::ProcessorExecutionWithFieldItem::Disabled::{Description}", GetType().Name, manipulator.Description);
}

}

if (HasStringTooLong(fieldItem))
{
fieldItem.Value = fieldItem.Value.ToString().Substring(0, Math.Min(fieldItem.Value.ToString().Length, Options.MaxStringLength));
Expand Down

0 comments on commit 459d674

Please sign in to comment.