feature: add option to enable --keep-index option of git stash push command (#610)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-10-28 16:51:42 +08:00
parent 3e6e0befaa
commit 566d36ca59
No known key found for this signature in database
6 changed files with 22 additions and 5 deletions

View file

@ -17,17 +17,19 @@ namespace SourceGit.Commands
return Exec();
}
public bool Push(List<Models.Change> changes, string message, bool onlyStaged)
public bool Push(List<Models.Change> changes, string message, bool onlyStaged, bool keepIndex)
{
var pathsBuilder = new StringBuilder();
var indexOpts = keepIndex ? "--keep-index" : "";
if (onlyStaged)
{
foreach (var c in changes)
pathsBuilder.Append($"\"{c.Path}\" ");
var paths = pathsBuilder.ToString();
Args = $"stash push --staged -m \"{message}\" -- {paths}";
Args = $"stash push {indexOpts} --staged -m \"{message}\" -- {paths}";
}
else
{
@ -53,7 +55,7 @@ namespace SourceGit.Commands
}
var paths = pathsBuilder.ToString();
Args = $"stash push -m \"{message}\" -- {paths}";
Args = $"stash push {indexOpts} -m \"{message}\" -- {paths}";
}
return Exec();