From cf99a8e3bd5532e00bea39925e7fdbb31b5408ef Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Feb 2014 02:09:37 +0000 Subject: [PATCH 1/4] fixing the git capabilities --- warmup/commands/AddPathItemReplacement.cs | 163 ++++++++++++++++++++++ warmup/infrastructure/exporters/Git.cs | 138 +++++++++++++----- warmup/warmup.csproj | 2 +- 3 files changed, 268 insertions(+), 35 deletions(-) create mode 100644 warmup/commands/AddPathItemReplacement.cs diff --git a/warmup/commands/AddPathItemReplacement.cs b/warmup/commands/AddPathItemReplacement.cs new file mode 100644 index 0000000..9686457 --- /dev/null +++ b/warmup/commands/AddPathItemReplacement.cs @@ -0,0 +1,163 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System; +using System.Configuration; +using warmup.infrastructure; +using warmup.infrastructure.settings; +using System.IO; + + +namespace warmup.commands +{ + + [Command("addPathItemReplacement")] + public class AddPathItemReplacement : ICommand + { + public void Run(string[] args) + { + if (args == null || args.Length != 3) + { + ShowHelp(); + Environment.Exit(-1); + } + + + + var find = args[1]; + var replace = args[2]; + var path = args[3]; + + + + + + Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); + WarmupConfiguration warmupConfig = config.GetSection("warmup") as WarmupConfiguration; + + if (warmupConfig != null) + { + warmupConfig.SectionInformation.ForceSave = true; + + bool itemFound = false; + + foreach (TextReplaceItem replaceItem in warmupConfig.TextReplaceCollection) + { + if (replaceItem.Find.ToLower() == find.ToLower()) + { + Console.WriteLine("Replacing '{0}' value of '{1}' with '{2}'.", find, replaceItem.Replace, replace); + replaceItem.Replace = replace; + itemFound = true; + } + } + + if (!itemFound) + { + Console.WriteLine("Adding '{0}' with a replacement of '{1}' to the configuration.", find, replace.Replace("\"", string.Empty)); + warmupConfig.TextReplaceCollection.Add(new TextReplaceItem { Find = find, Replace = replace }); + } + + // Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); + config.Save(ConfigurationSaveMode.Full); + } + } + + public void ShowHelp() + { + CommonHelp.ShowHelp(); + Console.WriteLine("----------"); + Console.WriteLine("usage for addTextReplacement"); + Console.WriteLine("----------"); + Console.WriteLine("warmup addTextReplacement findName replacementName"); + Console.WriteLine("Example: warmup addTextReplacement __COMPANY__ \"somewheres, inc\""); + Console.WriteLine("Example: '__COMPANY__' is the token to search for, \"somwheres, inc\" is the replacement text."); + } + } + + private class FileRenamer + { + /// + /// It will rename filename into title case format. + /// + /// Directory in where this rename process will take place to rename all the containing files. + /// + /// If it requires to do extra formatting for example, replace special charecters from the filename + /// then consumer of this method can pass filtering behavior via this predicate. + /// + public static void RenameFilesToTitleCase(string directoryName, Func predicate) + { + Rename(directoryName, predicate, System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase); + } + + /// + /// It will rename filename into lower case format. + /// + /// Directory in where this rename process will take place to rename all the containing files. + /// + /// If it requires to do extra formatting for example, replace special charecters from the filename + /// then consumer of this method can pass filtering behavior via this predicate. + /// + public static void RenameFilesToLowerCase(string directoryName, Func predicate) + { + Rename(directoryName, predicate, System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToLower); + } + + /// + /// It will rename filename into lower case format. + /// + /// Directory in where this rename process will take place to rename all the containing files. + /// + /// If it requires to do extra formatting for example, replace special charecters from the filename + /// then consumer of this method can pass filtering behavior via this predicate. + /// + public static void RenameFiles(string directoryName, Func predicate) + { + Rename(directoryName, predicate, s => s); + } + + /// + /// Rename the filenam with the new name based on the condition provided by predicate and casePredicate. + /// + /// Directory in where this rename process will take place to rename all the containing files. + /// Extra formatting to the filname. + /// This will point to the case changing method passed by calling method. + private static void Rename(string directoryName, Func predicate, Func casePredicate) + { + Directory.GetDirectories(directoryName).AsParallel().ToList().ForEach(directory => + { + if (Directory.GetDirectories(directory).Count() > 0) + Rename(directory, predicate, casePredicate); + Directory.GetFiles(directory).AsParallel().ToList().ForEach(file => + { + File.Move(file, casePredicate(GetNewFileName(predicate, directory, file))); + }); + }); + } + + + + /// + /// To get the new renamed filename. + /// + /// Formatting condition + /// The directory for which this rename will take place. + /// Formatted filename + /// This method will return formatted renamed filenamed combined with directoryname. + private static string GetNewFileName(Func predicate, string directory, string file) + { + return Path.Combine(Path.GetFullPath(directory), Filter(Path.GetFileName(file), predicate)); + } + + /// + /// To execute calling method provided formatting method. + /// + /// Filename to format + /// The delegate of the filename formatter. + /// Formatted filename. + private static string Filter(string data, Func predicate) + { + return !ReferenceEquals(predicate, null) ? predicate(data) : data; + } + } +} diff --git a/warmup/infrastructure/exporters/Git.cs b/warmup/infrastructure/exporters/Git.cs index 183730d..239fef1 100644 --- a/warmup/infrastructure/exporters/Git.cs +++ b/warmup/infrastructure/exporters/Git.cs @@ -1,56 +1,126 @@ using System; using System.Diagnostics; -using warmup.infrastructure.extractors; +// using warmup.infrastructure.extractors; using warmup.infrastructure.settings; +using System.IO; +using System.Net; namespace warmup.infrastructure.exporters { public class Git : BaseExporter { - public static void Clone(Uri sourceLocation, TargetDir target) + public override void Export(string sourceControlWarmupLocation, string templateName, TargetDir targetDir) { - var separationCharacters = new[] {".git"}; - string[] piecesOfPath = sourceLocation.ToString().Split(separationCharacters, StringSplitOptions.RemoveEmptyEntries); - if (piecesOfPath != null && piecesOfPath.Length > 0) + var gitsrc = (new Uri(sourceControlWarmupLocation)).IsFile + ? Path.Combine(sourceControlWarmupLocation, templateName) + : NewUri(sourceControlWarmupLocation, templateName).AbsoluteUri; + + var destination = targetDir == null + ? new TargetDir(Environment.CurrentDirectory) + : targetDir; + + var gitSrcPath = TestPath(gitsrc); + + var psi = new ProcessStartInfo("cmd", string.Format(" /c git clone {0} {1}", gitSrcPath, destination.FullPath)); + + psi.UseShellExecute = false; + psi.CreateNoWindow = true; + psi.RedirectStandardOutput = true; + psi.RedirectStandardError = true; + + //todo: better error handling + Console.WriteLine("Running: {0} {1}", psi.FileName, psi.Arguments); + string output, error = ""; + using (Process p = Process.Start(psi)) { - string sourceLocationToGit = piecesOfPath[0] + ".git"; + output = p.StandardOutput.ReadToEnd(); + error = p.StandardError.ReadToEnd(); + } - var psi = new ProcessStartInfo("cmd",string.Format(" /c git clone {0} {1}", sourceLocationToGit, target.FullPath)); + Console.WriteLine(output); + Console.WriteLine(error); - psi.UseShellExecute = false; - psi.CreateNoWindow = true; - psi.RedirectStandardOutput = true; - psi.RedirectStandardError = true; + } - //todo: better error handling - Console.WriteLine("Running: {0} {1}", psi.FileName, psi.Arguments); - string output, error = ""; - using (Process p = Process.Start(psi)) + private static string TestPath(string path) + { + return new Uri(path).IsFile + ? Directory.Exists(path) + ? path + : AdjustedPath(path) + : isValid(path) + ? path + : AdjustedPath(path); + } + + private static string AdjustedPath(string path) + { + return path.EndsWith(".git") + ? path + : path + ".git"; + } + + public static bool isValid(string url) + { + try + { + var urlReq = (HttpWebRequest)WebRequest.Create(url); + var urlRes = (HttpWebResponse)urlReq.GetResponse(); + var sStream = urlRes.GetResponseStream(); + + string read = new StreamReader(sStream).ReadToEnd(); + return true; + + } + catch (Exception ex) + { + //Url not valid + return false; + } + + } + + private static Uri NewUri(string baseUri, string relativeUri) + { + var r = CreateUri(baseUri, relativeUri); + if (r.Item1) + { + return r.Item2; + } + else + { + r = CreateUri(baseUri, ""); + if (r.Item1) { - output = p.StandardOutput.ReadToEnd(); - error = p.StandardError.ReadToEnd(); + return r.Item2; + } + else + { + throw new ArgumentException("The base is not valid"); } - - Console.WriteLine(output); - Console.WriteLine(error); - - var templateName = piecesOfPath[1]; - GitTemplateExtractor extractor = new GitTemplateExtractor(target, templateName); - extractor.Extract(); - //string git_directory = Path.Combine(target.FullPath, ".git"); - //if (Directory.Exists(git_directory)) - //{ - // Console.WriteLine("Deleting {0} directory", git_directory); - // Directory.Delete(git_directory, true); - //} } } - public override void Export(string sourceControlWarmupLocation, string templateName, TargetDir targetDir) + private static Tuple CreateUri(string baseUri, string relativeUri) + { + return CreateUri( + baseUri.EndsWith("/") + ? new Uri(baseUri) + : new Uri(baseUri + "/"), + relativeUri); + } + + private static Tuple CreateUri(Uri baseUri, string relativeUri) { + Uri ret; + return Tuple.Create(Uri.TryCreate(baseUri, relativeUri, out ret), ret); + } + + public static void Clone(Uri sourceLocation, TargetDir target) + { + } + + public static void Clone(string sourceLocation, TargetDir target) { - var baseUri = new Uri(WarmupConfiguration.settings.SourceControlWarmupLocation + templateName); - Console.WriteLine("git exporting to: {0}", targetDir.FullPath); - Clone(baseUri, targetDir); } } } \ No newline at end of file diff --git a/warmup/warmup.csproj b/warmup/warmup.csproj index 37ca9bb..b74f3b9 100644 --- a/warmup/warmup.csproj +++ b/warmup/warmup.csproj @@ -54,7 +54,7 @@ - + From 2f99662560aa0c7a35c3e1f87620a066d1173c64 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Feb 2014 02:15:53 +0000 Subject: [PATCH 2/4] removing unnecessary file --- warmup/commands/AddPathItemReplacement.cs | 163 ---------------------- 1 file changed, 163 deletions(-) delete mode 100644 warmup/commands/AddPathItemReplacement.cs diff --git a/warmup/commands/AddPathItemReplacement.cs b/warmup/commands/AddPathItemReplacement.cs deleted file mode 100644 index 9686457..0000000 --- a/warmup/commands/AddPathItemReplacement.cs +++ /dev/null @@ -1,163 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System; -using System.Configuration; -using warmup.infrastructure; -using warmup.infrastructure.settings; -using System.IO; - - -namespace warmup.commands -{ - - [Command("addPathItemReplacement")] - public class AddPathItemReplacement : ICommand - { - public void Run(string[] args) - { - if (args == null || args.Length != 3) - { - ShowHelp(); - Environment.Exit(-1); - } - - - - var find = args[1]; - var replace = args[2]; - var path = args[3]; - - - - - - Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); - WarmupConfiguration warmupConfig = config.GetSection("warmup") as WarmupConfiguration; - - if (warmupConfig != null) - { - warmupConfig.SectionInformation.ForceSave = true; - - bool itemFound = false; - - foreach (TextReplaceItem replaceItem in warmupConfig.TextReplaceCollection) - { - if (replaceItem.Find.ToLower() == find.ToLower()) - { - Console.WriteLine("Replacing '{0}' value of '{1}' with '{2}'.", find, replaceItem.Replace, replace); - replaceItem.Replace = replace; - itemFound = true; - } - } - - if (!itemFound) - { - Console.WriteLine("Adding '{0}' with a replacement of '{1}' to the configuration.", find, replace.Replace("\"", string.Empty)); - warmupConfig.TextReplaceCollection.Add(new TextReplaceItem { Find = find, Replace = replace }); - } - - // Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); - config.Save(ConfigurationSaveMode.Full); - } - } - - public void ShowHelp() - { - CommonHelp.ShowHelp(); - Console.WriteLine("----------"); - Console.WriteLine("usage for addTextReplacement"); - Console.WriteLine("----------"); - Console.WriteLine("warmup addTextReplacement findName replacementName"); - Console.WriteLine("Example: warmup addTextReplacement __COMPANY__ \"somewheres, inc\""); - Console.WriteLine("Example: '__COMPANY__' is the token to search for, \"somwheres, inc\" is the replacement text."); - } - } - - private class FileRenamer - { - /// - /// It will rename filename into title case format. - /// - /// Directory in where this rename process will take place to rename all the containing files. - /// - /// If it requires to do extra formatting for example, replace special charecters from the filename - /// then consumer of this method can pass filtering behavior via this predicate. - /// - public static void RenameFilesToTitleCase(string directoryName, Func predicate) - { - Rename(directoryName, predicate, System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase); - } - - /// - /// It will rename filename into lower case format. - /// - /// Directory in where this rename process will take place to rename all the containing files. - /// - /// If it requires to do extra formatting for example, replace special charecters from the filename - /// then consumer of this method can pass filtering behavior via this predicate. - /// - public static void RenameFilesToLowerCase(string directoryName, Func predicate) - { - Rename(directoryName, predicate, System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToLower); - } - - /// - /// It will rename filename into lower case format. - /// - /// Directory in where this rename process will take place to rename all the containing files. - /// - /// If it requires to do extra formatting for example, replace special charecters from the filename - /// then consumer of this method can pass filtering behavior via this predicate. - /// - public static void RenameFiles(string directoryName, Func predicate) - { - Rename(directoryName, predicate, s => s); - } - - /// - /// Rename the filenam with the new name based on the condition provided by predicate and casePredicate. - /// - /// Directory in where this rename process will take place to rename all the containing files. - /// Extra formatting to the filname. - /// This will point to the case changing method passed by calling method. - private static void Rename(string directoryName, Func predicate, Func casePredicate) - { - Directory.GetDirectories(directoryName).AsParallel().ToList().ForEach(directory => - { - if (Directory.GetDirectories(directory).Count() > 0) - Rename(directory, predicate, casePredicate); - Directory.GetFiles(directory).AsParallel().ToList().ForEach(file => - { - File.Move(file, casePredicate(GetNewFileName(predicate, directory, file))); - }); - }); - } - - - - /// - /// To get the new renamed filename. - /// - /// Formatting condition - /// The directory for which this rename will take place. - /// Formatted filename - /// This method will return formatted renamed filenamed combined with directoryname. - private static string GetNewFileName(Func predicate, string directory, string file) - { - return Path.Combine(Path.GetFullPath(directory), Filter(Path.GetFileName(file), predicate)); - } - - /// - /// To execute calling method provided formatting method. - /// - /// Filename to format - /// The delegate of the filename formatter. - /// Formatted filename. - private static string Filter(string data, Func predicate) - { - return !ReferenceEquals(predicate, null) ? predicate(data) : data; - } - } -} From 541ea3e4b7406116f5bf2f307adc9096d08f547e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Feb 2014 02:21:14 +0000 Subject: [PATCH 3/4] tidying & preparing for the pullrequest --- warmup/infrastructure/exporters/Git.cs | 2 +- .../extractors/GitTemplateExtractor.cs | 75 ------------------- warmup/warmup.csproj | 1 - 3 files changed, 1 insertion(+), 77 deletions(-) delete mode 100644 warmup/infrastructure/extractors/GitTemplateExtractor.cs diff --git a/warmup/infrastructure/exporters/Git.cs b/warmup/infrastructure/exporters/Git.cs index 239fef1..263c7ff 100644 --- a/warmup/infrastructure/exporters/Git.cs +++ b/warmup/infrastructure/exporters/Git.cs @@ -72,7 +72,7 @@ public static bool isValid(string url) return true; } - catch (Exception ex) + catch (Exception) { //Url not valid return false; diff --git a/warmup/infrastructure/extractors/GitTemplateExtractor.cs b/warmup/infrastructure/extractors/GitTemplateExtractor.cs deleted file mode 100644 index 17ebd85..0000000 --- a/warmup/infrastructure/extractors/GitTemplateExtractor.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -namespace warmup.infrastructure.extractors -{ - public class GitTemplateExtractor - { - private const StringComparison Comparison = StringComparison.InvariantCultureIgnoreCase; - private readonly TargetDir _target; - private readonly string _templateName; - - public GitTemplateExtractor(TargetDir target, string templateName) - { - _target = target; - _templateName = templateName; - } - - public void Extract() - { - var topParent = new DirectoryInfo(_target.FullPath); - var directories = topParent.GetDirectories(); - var files = topParent.GetFiles(); - - if (TemplateNotFound(directories, files)) return; - - CleanTopParent(directories, files); - - var templateDir = directories.FirstOrDefault(d => d.Name.Equals(_templateName, Comparison)); - if (templateDir != null) MoveTemplateContent(templateDir, topParent); - } - - private void CleanTopParent(IEnumerable directories, IEnumerable files) - { - foreach (var directory in directories.Where(directory => - directory.Name != _templateName)) - DeleteDirectory(directory); - foreach (var file in files.Where(file => - !file.Name.Equals(_templateName + file.Extension, Comparison))) - SafeDeleteFile(file); - } - - private bool TemplateNotFound(IEnumerable directories, IEnumerable files) - { - return !directories.Any(di => di.Name.Equals(_templateName, Comparison)) && - !files.Any(f => f.Name.Equals(_templateName + f.Extension, Comparison)); - } - - private static void SafeDeleteFile(FileInfo file) - { - file.Attributes = FileAttributes.Normal; - file.Delete(); - } - - private static void DeleteDirectory(DirectoryInfo directory) - { - foreach (var dir in directory.GetDirectories()) - DeleteDirectory(dir); - foreach (var file in directory.GetFiles()) - SafeDeleteFile(file); - directory.Attributes = FileAttributes.Normal; - directory.Delete(); - } - - private static void MoveTemplateContent(DirectoryInfo templateDir, DirectoryInfo destinationDir) - { - foreach (var dir in templateDir.GetDirectories()) - dir.MoveTo(Path.Combine(destinationDir.FullName, dir.Name)); - foreach (var file in templateDir.GetFiles()) - file.MoveTo(Path.Combine(destinationDir.FullName, file.Name)); - templateDir.Delete(); - } - } -} \ No newline at end of file diff --git a/warmup/warmup.csproj b/warmup/warmup.csproj index b74f3b9..88eb660 100644 --- a/warmup/warmup.csproj +++ b/warmup/warmup.csproj @@ -54,7 +54,6 @@ - From ab8d809cd5e918f5a3a96c0a00486aa1c024d593 Mon Sep 17 00:00:00 2001 From: James Tryand Date: Thu, 27 Feb 2014 11:15:48 +0000 Subject: [PATCH 4/4] minior tidyup and removing artifact .git repo --- warmup/Program.cs | 3 +- warmup/infrastructure/CommonHelp.cs | 7 +++ warmup/infrastructure/console/Verifier.cs | 52 ++++++++++++++++++ warmup/infrastructure/exporters/Git.cs | 54 ++++--------------- .../settings/WarmupConfiguration.cs | 6 +++ warmup/warmup.csproj | 1 + 6 files changed, 79 insertions(+), 44 deletions(-) create mode 100644 warmup/infrastructure/console/Verifier.cs diff --git a/warmup/Program.cs b/warmup/Program.cs index d3bf167..dcc7bf2 100644 --- a/warmup/Program.cs +++ b/warmup/Program.cs @@ -1,6 +1,7 @@ using System; using warmup.commands; using warmup.infrastructure; +using warmup.infrastructure.settings; namespace warmup { @@ -8,7 +9,7 @@ internal class Program { private static void Main(string[] args) { - if (args.Length == 0) + if (args.Length == 0) // || !WarmupConfiguration.settings.SourceControlWarmupLocationIsValid) { CommonHelp.ShowHelp(); Environment.Exit(-1); diff --git a/warmup/infrastructure/CommonHelp.cs b/warmup/infrastructure/CommonHelp.cs index fc94571..09588c5 100644 --- a/warmup/infrastructure/CommonHelp.cs +++ b/warmup/infrastructure/CommonHelp.cs @@ -16,6 +16,13 @@ public static void ShowHelp() WarmupConfiguration.settings.SourceControlType, WarmupConfiguration.settings.SourceControlWarmupLocation ); + if (!WarmupConfiguration.settings.SourceControlWarmupLocationIsValid) + { + + Console.WriteLine("----------"); + Console.WriteLine("The Source Control Warmup Location is not Valid"); + Console.WriteLine("Please ensure that '{0}' is accessible", WarmupConfiguration.settings.SourceControlWarmupLocation); + } Console.WriteLine("----------"); Console.WriteLine("usage"); Console.WriteLine("----------"); diff --git a/warmup/infrastructure/console/Verifier.cs b/warmup/infrastructure/console/Verifier.cs new file mode 100644 index 0000000..651f54a --- /dev/null +++ b/warmup/infrastructure/console/Verifier.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; +using System.Net; + +namespace warmup.infrastructure +{ + public static class Verifier + { + + + public static string TestPath(string path) + { + return new Uri(path).IsFile + ? Directory.Exists(path) + ? path + : AdjustedPath(path) + : isValid(path) + ? path + : AdjustedPath(path); + } + + public static string AdjustedPath(string path) + { + return path.EndsWith(".git") + ? path + : path + ".git"; + } + + public static bool isValid(string url) + { + try + { + var urlReq = (HttpWebRequest)WebRequest.Create(url); + var urlRes = (HttpWebResponse)urlReq.GetResponse(); + var sStream = urlRes.GetResponseStream(); + + string read = new StreamReader(sStream).ReadToEnd(); + return true; + + } + catch (Exception) + { + //Url not valid + return false; + } + + } + } +} diff --git a/warmup/infrastructure/exporters/Git.cs b/warmup/infrastructure/exporters/Git.cs index 263c7ff..b295801 100644 --- a/warmup/infrastructure/exporters/Git.cs +++ b/warmup/infrastructure/exporters/Git.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics; -// using warmup.infrastructure.extractors; using warmup.infrastructure.settings; using System.IO; using System.Net; @@ -19,7 +18,7 @@ public override void Export(string sourceControlWarmupLocation, string templateN ? new TargetDir(Environment.CurrentDirectory) : targetDir; - var gitSrcPath = TestPath(gitsrc); + var gitSrcPath = Verifier.TestPath(gitsrc); var psi = new ProcessStartInfo("cmd", string.Format(" /c git clone {0} {1}", gitSrcPath, destination.FullPath)); @@ -37,47 +36,16 @@ public override void Export(string sourceControlWarmupLocation, string templateN error = p.StandardError.ReadToEnd(); } + RemoveGitConfig(destination); + Console.WriteLine(output); Console.WriteLine(error); } - private static string TestPath(string path) + private static void RemoveGitConfig(TargetDir destination) { - return new Uri(path).IsFile - ? Directory.Exists(path) - ? path - : AdjustedPath(path) - : isValid(path) - ? path - : AdjustedPath(path); - } - - private static string AdjustedPath(string path) - { - return path.EndsWith(".git") - ? path - : path + ".git"; - } - - public static bool isValid(string url) - { - try - { - var urlReq = (HttpWebRequest)WebRequest.Create(url); - var urlRes = (HttpWebResponse)urlReq.GetResponse(); - var sStream = urlRes.GetResponseStream(); - - string read = new StreamReader(sStream).ReadToEnd(); - return true; - - } - catch (Exception) - { - //Url not valid - return false; - } - + Directory.Delete(path: Path.Combine(destination.FullPath, ".git"), recursive: true); } private static Uri NewUri(string baseUri, string relativeUri) @@ -115,12 +83,12 @@ private static Tuple CreateUri(Uri baseUri, string relativeUri) { return Tuple.Create(Uri.TryCreate(baseUri, relativeUri, out ret), ret); } - public static void Clone(Uri sourceLocation, TargetDir target) - { - } + //public static void Clone(Uri sourceLocation, TargetDir target) + //{ + //} - public static void Clone(string sourceLocation, TargetDir target) - { - } + //public static void Clone(string sourceLocation, TargetDir target) + //{ + //} } } \ No newline at end of file diff --git a/warmup/infrastructure/settings/WarmupConfiguration.cs b/warmup/infrastructure/settings/WarmupConfiguration.cs index 51c74a5..0a8cfb1 100644 --- a/warmup/infrastructure/settings/WarmupConfiguration.cs +++ b/warmup/infrastructure/settings/WarmupConfiguration.cs @@ -27,6 +27,12 @@ public string SourceControlWarmupLocation get { return (string) this["sourceControlWarmupLocation"]; } } + public bool SourceControlWarmupLocationIsValid + { + get { return Verifier.isValid((string)this["sourceControlWarmupLocation"]); } + } + + /// /// The token to replace in the warmup templates. Not required, default value is "__NAME__" /// diff --git a/warmup/warmup.csproj b/warmup/warmup.csproj index 88eb660..761cbc7 100644 --- a/warmup/warmup.csproj +++ b/warmup/warmup.csproj @@ -50,6 +50,7 @@ +