From de564d89fff554cbfa403834da624de508478cfc Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Wed, 29 Jun 2011 20:28:49 +0100 Subject: [PATCH] repo: add a property that shows the currenly unsynced paths (to hook up with the badger) --- SparkleLib/Git/SparkleRepoGit.cs | 28 ++++++++++++++++++++++++++++ SparkleLib/SparkleRepoBase.cs | 7 +++++++ SparkleShare/SparkleController.cs | 5 +++++ 3 files changed, 40 insertions(+) diff --git a/SparkleLib/Git/SparkleRepoGit.cs b/SparkleLib/Git/SparkleRepoGit.cs index 3f5fe3c5..f0ae14d0 100644 --- a/SparkleLib/Git/SparkleRepoGit.cs +++ b/SparkleLib/Git/SparkleRepoGit.cs @@ -52,6 +52,34 @@ namespace SparkleLib { } + public override string [] UnsyncedFilePaths { + get { + List file_paths = new List (); + + 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 { diff --git a/SparkleLib/SparkleRepoBase.cs b/SparkleLib/SparkleRepoBase.cs index 7c18583c..056b4cb3 100644 --- a/SparkleLib/SparkleRepoBase.cs +++ b/SparkleLib/SparkleRepoBase.cs @@ -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\.-]+)(/|:)"); diff --git a/SparkleShare/SparkleController.cs b/SparkleShare/SparkleController.cs index caa03e93..2efea66c 100644 --- a/SparkleShare/SparkleController.cs +++ b/SparkleShare/SparkleController.cs @@ -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 ||