Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit aee0c4a

Browse files
authored
Merge branch 'master' into fixes/right-click-revert
2 parents 3dfdb41 + 85d0a91 commit aee0c4a

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/GitHub.Api/Git/Tasks/GitCommitTask.cs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,37 @@ namespace GitHub.Unity
66
class GitCommitTask : ProcessTask<string>
77
{
88
private const string TaskName = "git commit";
9+
10+
private readonly string message;
11+
private readonly string body;
912
private readonly string arguments;
1013

14+
private NPath tempFile;
15+
1116
public GitCommitTask(string message, string body,
1217
CancellationToken token, IOutputProcessor<string> processor = null)
1318
: base(token, processor ?? new SimpleOutputProcessor())
1419
{
1520
Guard.ArgumentNotNullOrWhiteSpace(message, "message");
1621

22+
this.message = message;
23+
this.body = body ?? string.Empty;
24+
1725
Name = TaskName;
18-
arguments = "-c i18n.commitencoding=utf8 commit ";
19-
arguments += String.Format(" -m \"{0}\"", message);
20-
if (!String.IsNullOrEmpty(body))
21-
arguments += String.Format(" -m \"{0}\"", body);
26+
tempFile = NPath.GetTempFilename("GitCommitTask");
27+
arguments = $"-c i18n.commitencoding=utf8 commit --file \"{tempFile}\"";
28+
}
29+
30+
protected override void RaiseOnStart()
31+
{
32+
base.RaiseOnStart();
33+
tempFile.WriteAllLines(new [] { message, Environment.NewLine, body });
34+
}
35+
36+
protected override void RaiseOnEnd()
37+
{
38+
tempFile.DeleteIfExists();
39+
base.RaiseOnEnd();
2240
}
2341

2442
public override string ProcessArguments { get { return arguments; } }

0 commit comments

Comments
 (0)