Skip to content

Commit

Permalink
Issue chucknorris#120 (Pass version via command line argument)
Browse files Browse the repository at this point in the history
 - Add CommandLineVersionResolver.cs which extracts version directly from a string.
 - Update VersionResolverBuilder.cs to include the new resolver. Logic now groups the file based resolvers together and skips them if the command line resolver is valid.
 - Added Version property to the configuration objects.
 - Fix small typo / spelling error (already submitted in Pull Request chucknorris#134
  • Loading branch information
alexandermlharris committed Jan 27, 2014
1 parent 7a02c2a commit 3a94914
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 7 deletions.
2 changes: 2 additions & 0 deletions product/roundhouse.tasks/Roundhouse.cs
Expand Up @@ -53,6 +53,8 @@ bool ITask.Execute()

public string RepositoryPath { get; set; }

public string Version { get; set; }

public string VersionFile { get; set; }

public string VersionXPath { get; set; }
Expand Down
1 change: 1 addition & 0 deletions product/roundhouse/consoles/DefaultConfiguration.cs
Expand Up @@ -16,6 +16,7 @@ public sealed class DefaultConfiguration : ConfigurationPropertyHolder
public int CommandTimeoutAdmin { get; set; }
public string SqlFilesDirectory { get; set; }
public string RepositoryPath { get; set; }
public string Version { get; set; }
public string VersionFile { get; set; }
public string VersionXPath { get; set; }
public string AlterDatabaseFolderName { get; set; }
Expand Down
Expand Up @@ -8,14 +8,23 @@ public class VersionResolverBuilder
{
public static VersionResolver build(FileSystemAccess file_system, ConfigurationPropertyHolder configuration_property_holder)
{
VersionResolver xml_version_finder = new XmlFileVersionResolver(file_system, configuration_property_holder.VersionXPath, configuration_property_holder.VersionFile);
VersionResolver dll_version_finder = new DllFileVersionResolver(file_system, configuration_property_holder.VersionFile);
VersionResolver text_version_finder = new TextVersionResolver(file_system, configuration_property_holder.VersionFile);
VersionResolver script_number_version_finder = new ScriptfileVersionResolver(file_system, configuration_property_holder);
VersionResolver commandLine_version_finder = new CommandLineVersionResolver(configuration_property_holder.Version);

IEnumerable<VersionResolver> resolvers = new List<VersionResolver> { xml_version_finder, dll_version_finder, text_version_finder, script_number_version_finder };
if (commandLine_version_finder.meets_criteria())
{
return commandLine_version_finder;
}
else
{
VersionResolver xml_version_finder = new XmlFileVersionResolver(file_system, configuration_property_holder.VersionXPath, configuration_property_holder.VersionFile);
VersionResolver dll_version_finder = new DllFileVersionResolver(file_system, configuration_property_holder.VersionFile);
VersionResolver text_version_finder = new TextVersionResolver(file_system, configuration_property_holder.VersionFile);
VersionResolver script_number_version_finder = new ScriptfileVersionResolver(file_system, configuration_property_holder);

return new ComplexVersionResolver(resolvers);
IEnumerable<VersionResolver> resolvers = new List<VersionResolver> { xml_version_finder, dll_version_finder, text_version_finder, script_number_version_finder };

return new ComplexVersionResolver(resolvers);
}
}
}
}
30 changes: 30 additions & 0 deletions product/roundhouse/resolvers/CommandLineVersionResolver.cs
@@ -0,0 +1,30 @@
using roundhouse.infrastructure.logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace roundhouse.resolvers
{
public sealed class CommandLineVersionResolver : VersionResolver
{
private readonly string _version;

public CommandLineVersionResolver(string version)
{
_version = version;
}
public bool meets_criteria()
{
return !string.IsNullOrEmpty(_version);
}

public string resolve_version()
{
Log.bound_to(this).log_an_info_event_containing(
" Found version {0} from command line argument.", _version);

return _version;
}
}
}
1 change: 1 addition & 0 deletions product/roundhouse/roundhouse.csproj
Expand Up @@ -130,6 +130,7 @@
<Compile Include="parameters\AdoNetParameter.cs" />
<Compile Include="parameters\IParameter.cs" />
<Compile Include="Migrate.cs" />
<Compile Include="resolvers\CommandLineVersionResolver.cs" />
<Compile Include="resolvers\ScriptfileVersionResolver.cs" />
<Compile Include="resolvers\TextVersionResolver.cs" />
<Compile Include="RoundhousEFluentNHibernateDiffingType.cs" />
Expand Down
2 changes: 1 addition & 1 deletion product/roundhouse/runners/RoundhouseMigrationRunner.cs
Expand Up @@ -76,7 +76,7 @@ public void run()

if (run_in_a_transaction && !database_migrator.database.supports_ddl_transactions)
{
Log.bound_to(this).log_a_warning_event_containing("You asked to run in a transaction, but this dabasetype doesn't support DDL transactions.");
Log.bound_to(this).log_a_warning_event_containing("You asked to run in a transaction, but this databasetype doesn't support DDL transactions.");
if (!silent)
{
Log.bound_to(this).log_an_info_event_containing("Please press enter to continue without transaction support...");
Expand Down

0 comments on commit 3a94914

Please sign in to comment.