Add each note to its own namespace to avoid conflicts
This commit is contained in:
parent
ebc49fe540
commit
17110efe4b
|
@ -19,6 +19,8 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace SparkleLib {
|
namespace SparkleLib {
|
||||||
|
@ -540,17 +542,21 @@ namespace SparkleLib {
|
||||||
|
|
||||||
public override void AddNote (string revision, string note)
|
public override void AddNote (string revision, string note)
|
||||||
{
|
{
|
||||||
|
int timestamp = (int) (DateTime.UtcNow - new DateTime (1970, 1, 1)).TotalSeconds;
|
||||||
|
|
||||||
// Create the note in one line for easier merging
|
// Create the note in one line for easier merging
|
||||||
note = "<note>" +
|
note = "<note>" +
|
||||||
" <user>" +
|
" <user>" +
|
||||||
" <name>" + SparkleConfig.DefaultConfig.UserName + "</name>" +
|
" <name>" + SparkleConfig.DefaultConfig.UserName + "</name>" +
|
||||||
" <email>" + SparkleConfig.DefaultConfig.UserEmail + "</email>" +
|
" <email>" + SparkleConfig.DefaultConfig.UserEmail + "</email>" +
|
||||||
" </user>" +
|
" </user>" +
|
||||||
" <timestamp>" + (int) (DateTime.UtcNow - new DateTime (1970, 1, 1)).TotalSeconds + "</timestamp>" +
|
" <timestamp>" + timestamp + "</timestamp>" +
|
||||||
" <body>" + note + "</body>" +
|
" <body>" + note + "</body>" +
|
||||||
"</note>";
|
"</note>";
|
||||||
|
|
||||||
SparkleGit git_notes = new SparkleGit (LocalPath, "notes append -m \"" + note + "\" " + revision);
|
string note_namespace = SHA1 (timestamp.ToString () + note);
|
||||||
|
SparkleGit git_notes = new SparkleGit (LocalPath,
|
||||||
|
"notes --ref=" + note_namespace + " append -m \"" + note + "\" " + revision);
|
||||||
git_notes.Start ();
|
git_notes.Start ();
|
||||||
git_notes.WaitForExit ();
|
git_notes.WaitForExit ();
|
||||||
|
|
||||||
|
@ -571,5 +577,15 @@ namespace SparkleLib {
|
||||||
return !File.Exists (file_path);
|
return !File.Exists (file_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Creates a SHA-1 hash of input
|
||||||
|
private string SHA1 (string s)
|
||||||
|
{
|
||||||
|
SHA1 sha1 = new SHA1CryptoServiceProvider ();
|
||||||
|
Byte[] bytes = ASCIIEncoding.Default.GetBytes (s);
|
||||||
|
Byte[] encoded_bytes = sha1.ComputeHash (bytes);
|
||||||
|
return BitConverter.ToString (encoded_bytes).ToLower ().Replace ("-", "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue