repo git: we only need to determine CurrentRevision once per session.
This commit is contained in:
parent
1100fa205b
commit
07b727bb72
|
@ -30,25 +30,31 @@ namespace SparkleLib {
|
|||
base (path, backend) { }
|
||||
|
||||
|
||||
private string identifier = null;
|
||||
|
||||
public override string Identifier {
|
||||
get {
|
||||
if (string.IsNullOrEmpty (this.identifier)) {
|
||||
|
||||
// Because git computes a hash based on content,
|
||||
// author, and timestamp; it is unique enough to
|
||||
// use the hash of the first commit as an identifier
|
||||
// for our folder
|
||||
SparkleGit git = new SparkleGit (LocalPath, "rev-list --reverse HEAD");
|
||||
git.Start ();
|
||||
// Because git computes a hash based on content,
|
||||
// author, and timestamp; it is unique enough to
|
||||
// use the hash of the first commit as an identifier
|
||||
// for our folder
|
||||
SparkleGit git = new SparkleGit (LocalPath, "rev-list --reverse HEAD");
|
||||
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 ();
|
||||
git.WaitForExit ();
|
||||
// Reading the standard output HAS to go before
|
||||
// WaitForExit, or it will hang forever on output > 4096 bytes
|
||||
string output = git.StandardOutput.ReadToEnd ();
|
||||
git.WaitForExit ();
|
||||
|
||||
if (output.Length < 40)
|
||||
return null;
|
||||
if (output.Length < 40)
|
||||
return null;
|
||||
|
||||
return output.Substring (0, 40);
|
||||
this.identifier = output.Substring (0, 40);
|
||||
}
|
||||
|
||||
return this.identifier;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue