mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-10-31 13:03:20 -07:00
enhance: using -- <pathspec>...
instead of --pathspec-from-file=<file>
(#404)
This commit is contained in:
parent
9a69f972a3
commit
e136d05789
1 changed files with 6 additions and 15 deletions
|
@ -1,5 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.Text;
|
||||||
|
|
||||||
namespace SourceGit.Commands
|
namespace SourceGit.Commands
|
||||||
{
|
{
|
||||||
|
@ -19,14 +19,11 @@ namespace SourceGit.Commands
|
||||||
|
|
||||||
public bool Push(List<Models.Change> changes, string message)
|
public bool Push(List<Models.Change> changes, string message)
|
||||||
{
|
{
|
||||||
var temp = Path.GetTempFileName();
|
var pathsBuilder = new StringBuilder();
|
||||||
var stream = new FileStream(temp, FileMode.Create);
|
|
||||||
var writer = new StreamWriter(stream);
|
|
||||||
|
|
||||||
var needAdd = new List<Models.Change>();
|
var needAdd = new List<Models.Change>();
|
||||||
foreach (var c in changes)
|
foreach (var c in changes)
|
||||||
{
|
{
|
||||||
writer.WriteLine(c.Path);
|
pathsBuilder.Append($"\"{c.Path}\" ");
|
||||||
|
|
||||||
if (c.WorkTree == Models.ChangeState.Added || c.WorkTree == Models.ChangeState.Untracked)
|
if (c.WorkTree == Models.ChangeState.Added || c.WorkTree == Models.ChangeState.Untracked)
|
||||||
{
|
{
|
||||||
|
@ -44,15 +41,9 @@ namespace SourceGit.Commands
|
||||||
needAdd.Clear();
|
needAdd.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.Flush();
|
var paths = pathsBuilder.ToString();
|
||||||
stream.Flush();
|
Args = $"stash push -m \"{message}\" -- {paths}";
|
||||||
writer.Close();
|
return Exec();
|
||||||
stream.Close();
|
|
||||||
|
|
||||||
Args = $"stash push -m \"{message}\" --pathspec-from-file=\"{temp}\"";
|
|
||||||
var succ = Exec();
|
|
||||||
File.Delete(temp);
|
|
||||||
return succ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Apply(string name)
|
public bool Apply(string name)
|
||||||
|
|
Loading…
Reference in a new issue