Don't rely on Git# for FormatCommitMessage ()
This commit is contained in:
parent
1c5e05685a
commit
c6d189f028
|
@ -482,7 +482,7 @@ namespace SparkleLib {
|
||||||
git.WaitForExit ();
|
git.WaitForExit ();
|
||||||
|
|
||||||
_CurrentHash = GetCurrentHash ();
|
_CurrentHash = GetCurrentHash ();
|
||||||
SparkleHelpers.DebugInfo ("Commit", "[" + Name + "] " + message + " (" + _CurrentHash);
|
SparkleHelpers.DebugInfo ("Commit", "[" + Name + "] " + message + " (" + _CurrentHash + ")");
|
||||||
|
|
||||||
SparkleEventArgs args = new SparkleEventArgs ("Commited") {
|
SparkleEventArgs args = new SparkleEventArgs ("Commited") {
|
||||||
Message = message
|
Message = message
|
||||||
|
@ -562,7 +562,6 @@ namespace SparkleLib {
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict detected...");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Conflict detected...");
|
||||||
|
|
||||||
foreach (string problem_file_name in Status.MergeConflict) {
|
foreach (string problem_file_name in Status.MergeConflict) {
|
||||||
|
|
||||||
SparkleGit git_ours = new SparkleGit (LocalPath,
|
SparkleGit git_ours = new SparkleGit (LocalPath,
|
||||||
"checkout --ours " + problem_file_name);
|
"checkout --ours " + problem_file_name);
|
||||||
git_ours.Start ();
|
git_ours.Start ();
|
||||||
|
@ -883,24 +882,32 @@ namespace SparkleLib {
|
||||||
// Creates a pretty commit message based on what has changed
|
// Creates a pretty commit message based on what has changed
|
||||||
private string FormatCommitMessage ()
|
private string FormatCommitMessage ()
|
||||||
{
|
{
|
||||||
// RepositoryStatus contains the following properties (all HashSet <string>)
|
List<string> Added = new List<string> ();
|
||||||
//
|
List<string> Modified = new List<string> ();
|
||||||
// * Added ---> added and staged
|
List<string> Removed = new List<string> ();
|
||||||
// * MergeConflict --->
|
string file_name = "";
|
||||||
// * Missing ---> removed but not staged
|
string message = null;
|
||||||
// * Modified ---> modified but not staged
|
|
||||||
// * Removed ---> removed and staged
|
|
||||||
// * Staged ---> modified and staged
|
|
||||||
// * Untracked ---> added but not staged
|
|
||||||
//
|
|
||||||
// Because we create the commit message, we only need to consider the staged changes
|
|
||||||
RepositoryStatus status = Index.Status;
|
|
||||||
|
|
||||||
string file_name = "";
|
SparkleGit git_status = new SparkleGit (LocalPath, "status --porcelain");
|
||||||
string message = null;
|
git_status.Start ();
|
||||||
|
|
||||||
if (status.Added.Count > 0) {
|
// Reading the standard output HAS to go before
|
||||||
foreach (string added in status.Added) {
|
// WaitForExit, or it will hang forever on output > 4096 bytes
|
||||||
|
string output = git_status.StandardOutput.ReadToEnd ();
|
||||||
|
git_status.WaitForExit ();
|
||||||
|
|
||||||
|
string [] lines = output.Split ("\n".ToCharArray ());
|
||||||
|
foreach (string line in lines) {
|
||||||
|
if (line.StartsWith ("A"))
|
||||||
|
Added.Add (line.Substring (2));
|
||||||
|
else if (line.StartsWith ("M"))
|
||||||
|
Modified.Add (line.Substring (2));
|
||||||
|
else if (line.StartsWith ("D"))
|
||||||
|
Removed.Add (line.Substring (2));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Added.Count > 0) {
|
||||||
|
foreach (string added in Added) {
|
||||||
file_name = added;
|
file_name = added;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -908,8 +915,8 @@ namespace SparkleLib {
|
||||||
message = "+ ‘" + file_name + "’";
|
message = "+ ‘" + file_name + "’";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status.Staged.Count > 0) {
|
if (Modified.Count > 0) {
|
||||||
foreach (string modified in status.Staged) {
|
foreach (string modified in Modified) {
|
||||||
file_name = modified;
|
file_name = modified;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -917,9 +924,8 @@ namespace SparkleLib {
|
||||||
message = "/ ‘" + file_name + "’";
|
message = "/ ‘" + file_name + "’";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status.Removed.Count > 0) {
|
if (Removed.Count > 0) {
|
||||||
|
foreach (string removed in Removed) {
|
||||||
foreach (string removed in status.Removed) {
|
|
||||||
file_name = removed;
|
file_name = removed;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -927,9 +933,9 @@ namespace SparkleLib {
|
||||||
message = "- ‘" + file_name + "’";
|
message = "- ‘" + file_name + "’";
|
||||||
}
|
}
|
||||||
|
|
||||||
int changes_count = (status.Added.Count +
|
int changes_count = (Added.Count +
|
||||||
status.Staged.Count +
|
Modified.Count +
|
||||||
status.Removed.Count);
|
Removed.Count);
|
||||||
|
|
||||||
if (changes_count > 1)
|
if (changes_count > 1)
|
||||||
message += " + " + (changes_count - 1);
|
message += " + " + (changes_count - 1);
|
||||||
|
|
Loading…
Reference in a new issue