From 66b37c2270c86dc6376b916065653b9021573c4d Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sun, 4 Nov 2012 16:27:39 +0000 Subject: [PATCH] Allow using periods '.' and underscores '_' (will be replaced by spaces locally) in project names. fixes #1046 --- SparkleLib/SparkleFetcherBase.cs | 18 ++++++++---------- SparkleShare/Common/Plugins/own-server.xml | 2 +- SparkleShare/SparkleControllerBase.cs | 9 ++++++--- SparkleShare/SparkleSetupController.cs | 16 +++++++++++++--- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/SparkleLib/SparkleFetcherBase.cs b/SparkleLib/SparkleFetcherBase.cs index 74605def..4ae714a6 100755 --- a/SparkleLib/SparkleFetcherBase.cs +++ b/SparkleLib/SparkleFetcherBase.cs @@ -339,17 +339,15 @@ namespace SparkleLib { } - public static string GetBackend (string path) + public static string GetBackend (string address) { - string extension = Path.GetExtension (path); - - if (!string.IsNullOrEmpty (extension)) { - extension = extension.Substring (1); - char [] letters = extension.ToCharArray (); - letters [0] = char.ToUpper (letters [0]); - - return new string (letters); - + Uri uri = new Uri (address); + int index_of_plus = uri.Scheme.IndexOf ("+"); + + if (index_of_plus > -1) { + string backend = uri.Scheme.Substring (index_of_plus + 1); + return char.ToUpper (backend [0]) + backend.Substring (1); + } else { return "Git"; } diff --git a/SparkleShare/Common/Plugins/own-server.xml b/SparkleShare/Common/Plugins/own-server.xml index a0c209be..c8f3d04e 100644 --- a/SparkleShare/Common/Plugins/own-server.xml +++ b/SparkleShare/Common/Plugins/own-server.xml @@ -9,7 +9,7 @@
- [user@]hostname[:port] + ssh://[user@]hostname[:port]
diff --git a/SparkleShare/SparkleControllerBase.cs b/SparkleShare/SparkleControllerBase.cs index 795fb200..b828c5ae 100644 --- a/SparkleShare/SparkleControllerBase.cs +++ b/SparkleShare/SparkleControllerBase.cs @@ -523,9 +523,12 @@ namespace SparkleShare { File.SetAttributes (tmp_path, File.GetAttributes (tmp_path) | FileAttributes.Hidden); } - string canonical_name = Path.GetFileNameWithoutExtension (remote_path); + string canonical_name = Path.GetFileName (remote_path); string tmp_folder = Path.Combine (tmp_path, canonical_name); - string backend = SparkleFetcherBase.GetBackend (remote_path); + string backend = SparkleFetcherBase.GetBackend (address); + + if (address.StartsWith ("ssh+")) + address = "ssh" + address.Substring (address.IndexOf ("://")); try { this.fetcher = (SparkleFetcherBase) Activator.CreateInstance ( @@ -603,7 +606,7 @@ namespace SparkleShare { this.watcher.EnableRaisingEvents = false; this.fetcher.Complete (); - string canonical_name = Path.GetFileNameWithoutExtension (this.fetcher.RemoteUrl.AbsolutePath); + string canonical_name = Path.GetFileName (this.fetcher.RemoteUrl.AbsolutePath); canonical_name = canonical_name.Replace ("-crypto", ""); canonical_name = canonical_name.Replace ("_", " "); diff --git a/SparkleShare/SparkleSetupController.cs b/SparkleShare/SparkleSetupController.cs index 38c786ba..303909a1 100755 --- a/SparkleShare/SparkleSetupController.cs +++ b/SparkleShare/SparkleSetupController.cs @@ -136,7 +136,8 @@ namespace SparkleShare { Plugins.Insert (0, new SparklePlugin (xml_file_path)); } else if (xml_file_path.EndsWith ("ssnet.xml")) { - // Plugins.Insert ((local_plugins_count + 1), new SparklePlugin (xml_file_path)); TODO: Skip this plugin for now + // Plugins.Insert ((local_plugins_count + 1), new SparklePlugin (xml_file_path)); + // TODO: Skip this plugin for now } else { Plugins.Add (new SparklePlugin (xml_file_path)); @@ -341,7 +342,11 @@ namespace SparkleShare { public void AddPageCompleted (string address, string remote_path) { - SyncingFolder = Path.GetFileNameWithoutExtension (remote_path); + SyncingFolder = Path.GetFileName (remote_path); + + if (remote_path.EndsWith (".git")) + SyncingFolder = remote_path.Substring (0, remote_path.Length - 4); + SyncingFolder = SyncingFolder.Replace ("-crypto", ""); ProgressBarPercentage = 1.0; @@ -424,7 +429,12 @@ namespace SparkleShare { public void InvitePageCompleted () { - SyncingFolder = Path.GetFileNameWithoutExtension (PendingInvite.RemotePath); + SyncingFolder = Path.GetFileName (PendingInvite.RemotePath); + + if (PendingInvite.RemotePath.EndsWith (".git")) + SyncingFolder = PendingInvite.RemotePath.Substring (0, PendingInvite.RemotePath.Length - 4); + + SyncingFolder = SyncingFolder.Replace ("-crypto", ""); PreviousAddress = PendingInvite.Address; PreviousPath = PendingInvite.RemotePath;