config: add url as part of the folder config xml
This commit is contained in:
parent
f35a46d6c8
commit
857cf4e57d
|
@ -29,18 +29,6 @@ namespace SparkleLib {
|
|||
base (path, backend) { }
|
||||
|
||||
|
||||
public override string Url {
|
||||
get {
|
||||
SparkleGit git = new SparkleGit (LocalPath, "config --get remote.origin.url");
|
||||
git.Start ();
|
||||
git.WaitForExit ();
|
||||
|
||||
string output = git.StandardOutput.ReadToEnd ();
|
||||
return output.TrimEnd ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override string Identifier {
|
||||
get {
|
||||
|
||||
|
|
|
@ -29,23 +29,6 @@ namespace SparkleLib {
|
|||
base (path, backend) { }
|
||||
|
||||
|
||||
public override string Url {
|
||||
get {
|
||||
string repo_config_file_path = SparkleHelpers.CombineMore (LocalPath, ".hg", "hgrc");
|
||||
Regex regex = new Regex (@"default = (.+)");
|
||||
|
||||
foreach (string line in File.ReadAllLines (repo_config_file_path)) {
|
||||
Match match = regex.Match (line);
|
||||
|
||||
if (match.Success)
|
||||
return match.Groups [1].Value.TrimEnd ();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override string Identifier {
|
||||
get {
|
||||
SparkleHg hg = new SparkleHg (LocalPath, "log -r : --limit 1 --template \"{node}\"");
|
||||
|
|
|
@ -29,13 +29,6 @@ namespace SparkleLib {
|
|||
base (path, backend) { }
|
||||
|
||||
|
||||
public override string Url {
|
||||
get {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override string Identifier {
|
||||
get {
|
||||
return "sparkles";
|
||||
|
|
|
@ -121,17 +121,20 @@ namespace SparkleLib {
|
|||
}
|
||||
|
||||
|
||||
public void AddFolder (string name, string backend)
|
||||
public void AddFolder (string name, string url, string backend)
|
||||
{
|
||||
XmlNode node_folder = CreateNode (XmlNodeType.Element, "folder", null);
|
||||
|
||||
XmlNode node_name = CreateElement ("name");
|
||||
node_name.InnerText = name;
|
||||
|
||||
XmlNode node_url = CreateElement ("url");
|
||||
node_url.InnerText = url;
|
||||
|
||||
XmlNode node_backend = CreateElement ("backend");
|
||||
node_backend.InnerText = backend;
|
||||
|
||||
XmlNode node_folder = CreateNode (XmlNodeType.Element, "folder", null);
|
||||
node_folder.AppendChild (node_name);
|
||||
node_folder.AppendChild (node_url);
|
||||
node_folder.AppendChild (node_backend);
|
||||
|
||||
XmlNode node_root = SelectSingleNode ("/sparkleshare");
|
||||
|
@ -174,6 +177,17 @@ namespace SparkleLib {
|
|||
}
|
||||
|
||||
|
||||
public string GetUrlForFolder (string name)
|
||||
{
|
||||
foreach (XmlNode node_folder in SelectNodes ("/sparkleshare/folder")) {
|
||||
if (node_folder ["name"].InnerText.Equals (name))
|
||||
return node_folder ["url"].InnerText;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public string GetConfigOption (string name)
|
||||
{
|
||||
XmlNode node = SelectSingleNode ("/sparkleshare/" + name);
|
||||
|
|
|
@ -51,7 +51,6 @@ namespace SparkleLib {
|
|||
private bool has_changed = false;
|
||||
private Object change_lock = new Object ();
|
||||
|
||||
public abstract string Url { get; }
|
||||
public abstract bool AnyDifferences { get; }
|
||||
public abstract string Identifier { get; }
|
||||
public abstract string CurrentRevision { get; }
|
||||
|
@ -72,7 +71,6 @@ namespace SparkleLib {
|
|||
public event ChangesDetectedEventHandler ChangesDetected;
|
||||
|
||||
|
||||
// TODO: constructor (path, url, backend)
|
||||
public SparkleRepoBase (string path, SparkleBackend backend)
|
||||
{
|
||||
LocalPath = path;
|
||||
|
@ -154,7 +152,7 @@ namespace SparkleLib {
|
|||
public string Domain {
|
||||
get {
|
||||
Regex regex = new Regex (@"(@|://)([a-z0-9\.]+)(/|:)");
|
||||
Match match = regex.Match (Url);
|
||||
Match match = regex.Match (SparkleConfig.DefaultConfig.GetUrlForFolder (Name));
|
||||
|
||||
if (match.Success)
|
||||
return match.Groups [2].Value;
|
||||
|
@ -193,7 +191,8 @@ namespace SparkleLib {
|
|||
|
||||
public string RemoteName {
|
||||
get {
|
||||
return Path.GetFileNameWithoutExtension (Url);
|
||||
string url = SparkleConfig.DefaultConfig.GetUrlForFolder (Name);
|
||||
return Path.GetFileNameWithoutExtension (url);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -970,7 +970,7 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
SparkleConfig.DefaultConfig.AddFolder (target_folder_name, backend);
|
||||
SparkleConfig.DefaultConfig.AddFolder (target_folder_name, url, backend);
|
||||
AddRepository (target_folder_path);
|
||||
|
||||
if (FolderFetched != null)
|
||||
|
|
Loading…
Reference in a new issue