diff --git a/scripts/TouchinBuild/CommandBuilders/BuilderBackupCommands/BaseBackupCommandBuilder.py b/scripts/TouchinBuild/CommandBuilders/BuilderBackupCommands/BaseBackupCommandBuilder.py new file mode 100644 index 0000000..9dc6dae --- /dev/null +++ b/scripts/TouchinBuild/CommandBuilders/BuilderBackupCommands/BaseBackupCommandBuilder.py @@ -0,0 +1,14 @@ +from parsers.ValuesStriper import ValuesStripper + + +class BaseBackupCommandBuilder: + def __init__(self, ignoreBackupStr): + + if ignoreBackupStr: + splitter = ValuesStripper(',') + values = splitter.strip(ignoreBackupStr) + self.ignoreBackup = values + else: + self.ignoreBackup = [] + + print self.ignoreBackup \ No newline at end of file diff --git a/scripts/TouchinBuild/CommandBuilders/CreateBackupCommandBuilder.py b/scripts/TouchinBuild/CommandBuilders/BuilderBackupCommands/CreateBackupCommandBuilder.py similarity index 57% rename from scripts/TouchinBuild/CommandBuilders/CreateBackupCommandBuilder.py rename to scripts/TouchinBuild/CommandBuilders/BuilderBackupCommands/CreateBackupCommandBuilder.py index 5bd0bd3..1921940 100644 --- a/scripts/TouchinBuild/CommandBuilders/CreateBackupCommandBuilder.py +++ b/scripts/TouchinBuild/CommandBuilders/BuilderBackupCommands/CreateBackupCommandBuilder.py @@ -1,10 +1,11 @@ +from CommandBuilders.BuilderBackupCommands.BaseBackupCommandBuilder import BaseBackupCommandBuilder from commands.BaseBackupCommand.CreateBackupCommand import CreateBackupCommand from parsers.ParserBackup.CreateBackupParser import CreateBackupParser -class CreateBackupCommandBuilder: - def __init__(self): - pass +class CreateBackupCommandBuilder(BaseBackupCommandBuilder): + def __init__(self, ignoreBackupStr): + BaseBackupCommandBuilder.__init__(self, ignoreBackupStr) def isCreateBackup(self, line): assert line is not None @@ -18,5 +19,5 @@ class CreateBackupCommandBuilder: parser = CreateBackupParser() parser.parseLine(line) - command = CreateBackupCommand() + command = CreateBackupCommand(self.ignoreBackup) return command diff --git a/scripts/TouchinBuild/CommandBuilders/DeleteBackupCommandBuilder.py b/scripts/TouchinBuild/CommandBuilders/BuilderBackupCommands/DeleteBackupCommandBuilder.py similarity index 58% rename from scripts/TouchinBuild/CommandBuilders/DeleteBackupCommandBuilder.py rename to scripts/TouchinBuild/CommandBuilders/BuilderBackupCommands/DeleteBackupCommandBuilder.py index 53e9238..2e3ea3a 100644 --- a/scripts/TouchinBuild/CommandBuilders/DeleteBackupCommandBuilder.py +++ b/scripts/TouchinBuild/CommandBuilders/BuilderBackupCommands/DeleteBackupCommandBuilder.py @@ -1,10 +1,11 @@ +from CommandBuilders.BuilderBackupCommands.BaseBackupCommandBuilder import BaseBackupCommandBuilder from commands.BaseBackupCommand.DeleteBackupCommand import DeleteBackupCommand from parsers.ParserBackup.DeleteBackupParser import DeleteBackupParser -class DeleteBackupCommandBuilder: - def __init__(self): - pass +class DeleteBackupCommandBuilder(BaseBackupCommandBuilder): + def __init__(self, ignoreBackupStr): + BaseBackupCommandBuilder.__init__(self, ignoreBackupStr) def isDeleteBackup(self, line): assert line is not None @@ -20,5 +21,5 @@ class DeleteBackupCommandBuilder: parser = DeleteBackupParser() parser.parseLine(line) - command = DeleteBackupCommand() + command = DeleteBackupCommand(self.ignoreBackup) return command diff --git a/scripts/TouchinBuild/CommandBuilders/RestoreBackupCommandBuilder.py b/scripts/TouchinBuild/CommandBuilders/BuilderBackupCommands/RestoreBackupCommandBuilder.py similarity index 58% rename from scripts/TouchinBuild/CommandBuilders/RestoreBackupCommandBuilder.py rename to scripts/TouchinBuild/CommandBuilders/BuilderBackupCommands/RestoreBackupCommandBuilder.py index 0f391a1..29c459f 100644 --- a/scripts/TouchinBuild/CommandBuilders/RestoreBackupCommandBuilder.py +++ b/scripts/TouchinBuild/CommandBuilders/BuilderBackupCommands/RestoreBackupCommandBuilder.py @@ -1,10 +1,11 @@ +from CommandBuilders.BuilderBackupCommands.BaseBackupCommandBuilder import BaseBackupCommandBuilder from commands.BaseBackupCommand.RestoreBackupCommand import RestoreBackupCommand from parsers.ParserBackup.RestoreBackupParser import RestoreBackupParser -class RestoreBackupCommandBuilder: - def __init__(self): - pass +class RestoreBackupCommandBuilder(BaseBackupCommandBuilder): + def __init__(self, ignoreBackupStr): + BaseBackupCommandBuilder.__init__(self, ignoreBackupStr) def isRestoreBackup(self, line): assert line is not None @@ -20,5 +21,5 @@ class RestoreBackupCommandBuilder: parser = RestoreBackupParser() parser.parseLine(line) - command = RestoreBackupCommand() + command = RestoreBackupCommand(self.ignoreBackup) return command diff --git a/scripts/TouchinBuild/CommandBuilders/BuilderBackupCommands/__init__.py b/scripts/TouchinBuild/CommandBuilders/BuilderBackupCommands/__init__.py new file mode 100644 index 0000000..cc31abc --- /dev/null +++ b/scripts/TouchinBuild/CommandBuilders/BuilderBackupCommands/__init__.py @@ -0,0 +1 @@ +__author__ = 'rzaitov' diff --git a/scripts/TouchinBuild/Core/StepsRunner.py b/scripts/TouchinBuild/Core/StepsRunner.py index fefce63..a6085ee 100644 --- a/scripts/TouchinBuild/Core/StepsRunner.py +++ b/scripts/TouchinBuild/Core/StepsRunner.py @@ -1,7 +1,9 @@ +from CommandBuilders.BuilderBackupCommands.CreateBackupCommandBuilder import CreateBackupCommandBuilder +from CommandBuilders.BuilderBackupCommands.DeleteBackupCommandBuilder import DeleteBackupCommandBuilder +from CommandBuilders.BuilderBackupCommands.RestoreBackupCommandBuilder import RestoreBackupCommandBuilder + from CommandBuilders.CleanBuildCommandBuilder import CleanBuildCommandBuilder from CommandBuilders.CopyCommandBuilder import CopyCommandBuilder -from CommandBuilders.CreateBackupCommandBuilder import CreateBackupCommandBuilder -from CommandBuilders.DeleteBackupCommandBuilder import DeleteBackupCommandBuilder from CommandBuilders.InstallProfileCommandBuilder import InstallProfileCommandBuilder from CommandBuilders.MakeDirsCommandBuilder import MakeDirsCommandBuilder from CommandBuilders.PatchCsprojCommandBuilder import PatchCsprojCommandBuilder @@ -9,7 +11,6 @@ from CommandBuilders.PatchInfoPlistArrayCommandBuilder import PatchInfoPlistArra from CommandBuilders.PatchInfoplistCommandBuilder import PatchInfoplistCommandBuilder from CommandBuilders.PatchManifestCommandBuilder import PatchManifestCommandBuilder from CommandBuilders.RemoveProjectCommandBuilder import RemoveProjectCommandBuilder -from CommandBuilders.RestoreBackupCommandBuilder import RestoreBackupCommandBuilder from CommandBuilders.ShCommandBuilder import ShCommandBuilder from CommandBuilders.SignApkBuilder import SignApkCommandBuilder from CommandBuilders.TestflightCommandBuilder import TestflightCommandBuilder @@ -26,9 +27,6 @@ class StepsRunner: self.shCommandBuilder = ShCommandBuilder() self.removeProjectBuilder = RemoveProjectCommandBuilder() - self.createBackupBuilder = CreateBackupCommandBuilder() - self.restoreFromBackupBuilder = RestoreBackupCommandBuilder() - self.deleteBackupBuilder = DeleteBackupCommandBuilder() self.createDirs = MakeDirsCommandBuilder() self.patchCsproj = PatchCsprojCommandBuilder() self.patchInfoPlist = PatchInfoplistCommandBuilder(self.valueProvider) @@ -37,6 +35,12 @@ class StepsRunner: self.copyBuilder = CopyCommandBuilder() self.testflightBuilder = TestflightCommandBuilder() + ignoreBackup = config.get('ignore_backup', None) + self.createBackupBuilder = CreateBackupCommandBuilder(ignoreBackup) + self.restoreFromBackupBuilder = RestoreBackupCommandBuilder(ignoreBackup) + self.deleteBackupBuilder = DeleteBackupCommandBuilder(ignoreBackup) + + profilePrefix = config['project_name'] self.installProfileBuilder = InstallProfileCommandBuilder(profilePrefix) diff --git a/scripts/TouchinBuild/Tests/ManualTests/create_backup_test.py b/scripts/TouchinBuild/Tests/ManualTests/create_backup_test.py index c770259..676da36 100644 --- a/scripts/TouchinBuild/Tests/ManualTests/create_backup_test.py +++ b/scripts/TouchinBuild/Tests/ManualTests/create_backup_test.py @@ -1,8 +1,8 @@ -from CommandBuilders.CreateBackupCommandBuilder import CreateBackupCommandBuilder +from CommandBuilders.BuilderBackupCommands.CreateBackupCommandBuilder import CreateBackupCommandBuilder line = "create backup" -cmdBuilder = CreateBackupCommandBuilder() +cmdBuilder = CreateBackupCommandBuilder(None) command = cmdBuilder.getCommandFor(line) command.execute() \ No newline at end of file diff --git a/scripts/TouchinBuild/Tests/ManualTests/delete_backup_test.py b/scripts/TouchinBuild/Tests/ManualTests/delete_backup_test.py index 4c312c4..a885c7d 100644 --- a/scripts/TouchinBuild/Tests/ManualTests/delete_backup_test.py +++ b/scripts/TouchinBuild/Tests/ManualTests/delete_backup_test.py @@ -1,8 +1,8 @@ -from CommandBuilders.DeleteBackupCommandBuilder import DeleteBackupCommandBuilder +from CommandBuilders.BuilderBackupCommands.DeleteBackupCommandBuilder import DeleteBackupCommandBuilder line = "delete backup" -cmdBuilder = DeleteBackupCommandBuilder() +cmdBuilder = DeleteBackupCommandBuilder(None) command = cmdBuilder.getCommandFor(line) command.execute() \ No newline at end of file diff --git a/scripts/TouchinBuild/Tests/ManualTests/restore_backup_test.py b/scripts/TouchinBuild/Tests/ManualTests/restore_backup_test.py index a61e390..33d3a6f 100644 --- a/scripts/TouchinBuild/Tests/ManualTests/restore_backup_test.py +++ b/scripts/TouchinBuild/Tests/ManualTests/restore_backup_test.py @@ -1,8 +1,8 @@ -from CommandBuilders.RestoreBackupCommandBuilder import RestoreBackupCommandBuilder +from CommandBuilders.BuilderBackupCommands.RestoreBackupCommandBuilder import RestoreBackupCommandBuilder line = "restore from backup" -builder = RestoreBackupCommandBuilder() +builder = RestoreBackupCommandBuilder(None) command = builder.getCommandFor(line) command.execute() diff --git a/scripts/TouchinBuild/commands/BaseBackupCommand/BaseBackupCommand.py b/scripts/TouchinBuild/commands/BaseBackupCommand/BaseBackupCommand.py index aba3acc..da0ac3e 100644 --- a/scripts/TouchinBuild/commands/BaseBackupCommand/BaseBackupCommand.py +++ b/scripts/TouchinBuild/commands/BaseBackupCommand/BaseBackupCommand.py @@ -4,8 +4,14 @@ from commands.CommandBase import CommandBase class BaseBackupCommand(CommandBase): - def __init__(self): + def __init__(self, ignoreBackup): CommandBase.__init__(self) + + assert ignoreBackup is not None + + self.backupIgnore = ['.git', '.gitignore', '.DS_Store', 'backup'] + self.backupIgnore.extend(ignoreBackup) + self.folderPath = '.' # вычислять абсолютные пути надо на этапе создания комманды @@ -13,7 +19,6 @@ class BaseBackupCommand(CommandBase): self.srcAbsDirPath = self.getAbsSrc() self.backupDirAbsPath = self.getAbsDst() - self.backupIgnore = ['.git', '.gitignore', '.DS_Store', 'backup'] def getAbsSrc(self): return self.getAbs(self.folderPath) diff --git a/scripts/TouchinBuild/commands/BaseBackupCommand/CreateBackupCommand.py b/scripts/TouchinBuild/commands/BaseBackupCommand/CreateBackupCommand.py index cb559dd..1906257 100644 --- a/scripts/TouchinBuild/commands/BaseBackupCommand/CreateBackupCommand.py +++ b/scripts/TouchinBuild/commands/BaseBackupCommand/CreateBackupCommand.py @@ -4,8 +4,8 @@ from commands.BaseBackupCommand.BaseBackupCommand import BaseBackupCommand class CreateBackupCommand(BaseBackupCommand): - def __init__(self): - BaseBackupCommand.__init__(self) + def __init__(self, ignoreBackup): + BaseBackupCommand.__init__(self, ignoreBackup) def execute(self): #if os.path.exists(self.backupDirAbsPath): diff --git a/scripts/TouchinBuild/commands/BaseBackupCommand/DeleteBackupCommand.py b/scripts/TouchinBuild/commands/BaseBackupCommand/DeleteBackupCommand.py index c29f5ce..660240b 100644 --- a/scripts/TouchinBuild/commands/BaseBackupCommand/DeleteBackupCommand.py +++ b/scripts/TouchinBuild/commands/BaseBackupCommand/DeleteBackupCommand.py @@ -4,8 +4,8 @@ from commands.BaseBackupCommand.BaseBackupCommand import BaseBackupCommand class DeleteBackupCommand(BaseBackupCommand): - def __init__(self): - BaseBackupCommand.__init__(self) + def __init__(self, ignoreBackup): + BaseBackupCommand.__init__(self, ignoreBackup) def execute(self): if not os.path.exists(self.backupDirAbsPath): diff --git a/scripts/TouchinBuild/commands/BaseBackupCommand/RestoreBackupCommand.py b/scripts/TouchinBuild/commands/BaseBackupCommand/RestoreBackupCommand.py index 403d5f7..15faf3b 100644 --- a/scripts/TouchinBuild/commands/BaseBackupCommand/RestoreBackupCommand.py +++ b/scripts/TouchinBuild/commands/BaseBackupCommand/RestoreBackupCommand.py @@ -4,8 +4,8 @@ from commands.BaseBackupCommand.BaseBackupCommand import BaseBackupCommand class RestoreBackupCommand(BaseBackupCommand): - def __init__(self): - BaseBackupCommand.__init__(self) + def __init__(self, ignoreBackup): + BaseBackupCommand.__init__(self, ignoreBackup) def execute(self): if not os.path.exists(self.backupDirAbsPath): diff --git a/scripts/TouchinBuild/parsers/ValuesStriper.py b/scripts/TouchinBuild/parsers/ValuesStriper.py index 934cc84..7be6574 100644 --- a/scripts/TouchinBuild/parsers/ValuesStriper.py +++ b/scripts/TouchinBuild/parsers/ValuesStriper.py @@ -1,11 +1,13 @@ class ValuesStripper: - def __init__(self): - pass + def __init__(self, separator=':'): + assert separator is not None + + self.separator = separator def strip(self, valueStr): assert valueStr is not None - rawValues = valueStr.split(':') + rawValues = valueStr.split(self.separator) values = [name.strip() for name in rawValues] return values \ No newline at end of file diff --git a/scripts/settings.txt b/scripts/settings.txt index fe7c0cd..6eac6f7 100644 --- a/scripts/settings.txt +++ b/scripts/settings.txt @@ -4,6 +4,7 @@ version=0.0.0 # комментарий в тойже строке configs = 'appstore, staging, android' project_name = CoolApp sln_config = Release|iPhone +backup_ignore = .git, .gitignore, .DS_Store, backup, artifacts # ios platform settings #ios.steps = 'scripts/IosSteps.txt'