repo: add a property that shows the currenly unsynced paths (to hook up with the badger)

This commit is contained in:
Hylke Bons 2011-06-29 20:28:49 +01:00
parent 91003a2cf2
commit de564d89ff
3 changed files with 40 additions and 0 deletions

View file

@ -52,6 +52,34 @@ namespace SparkleLib {
}
public override string [] UnsyncedFilePaths {
get {
List<string> file_paths = new List<string> ();
SparkleGit git = new SparkleGit (LocalPath, "status --porcelain");
git.Start ();
// Reading the standard output HAS to go before
// WaitForExit, or it will hang forever on output > 4096 bytes
string output = git.StandardOutput.ReadToEnd ().TrimEnd ();
git.WaitForExit ();
string [] lines = output.Split ("\n".ToCharArray ());
foreach (string line in lines) {
if (line [1].ToString ().Equals ("M") ||
line [1].ToString ().Equals ("?") ||
line [1].ToString ().Equals ("A")) {
string path = line.Substring (3);
path = path.Trim ("\"".ToCharArray ());
file_paths.Add (path);
}
}
return file_paths.ToArray ();
}
}
public override string CurrentRevision {
get {

View file

@ -145,6 +145,13 @@ namespace SparkleLib {
}
public virtual string [] UnsyncedFilePaths {
get {
return new string [0];
}
}
public string Domain {
get {
Regex regex = new Regex (@"(@|://)([a-z0-9\.-]+)(/|:)");

View file

@ -555,6 +555,11 @@ namespace SparkleShare {
};
repo.SyncStatusChanged += delegate (SyncStatus status) {
/* if (status == SyncStatus.SyncUp) {
foreach (string path in repo.UnsyncedFilePaths)
Console.WriteLine (path);
}
*/
if (status == SyncStatus.Idle ||
status == SyncStatus.SyncUp ||
status == SyncStatus.SyncDown ||