sourcegit/src/Commands/QueryStashes.cs

49 lines
1.3 KiB
C#
Raw Normal View History

using System.Collections.Generic;
2021-04-29 05:05:55 -07:00
namespace SourceGit.Commands
{
public class QueryStashes : Command
{
public QueryStashes(string repo)
{
WorkingDirectory = repo;
Context = repo;
Args = "stash list --pretty=format:%H%n%ct%n%gd%n%s";
2021-04-29 05:05:55 -07:00
}
public List<Models.Stash> Result()
{
2021-04-29 05:05:55 -07:00
Exec();
return _stashes;
2021-04-29 05:05:55 -07:00
}
protected override void OnReadline(string line)
{
switch (_nextLineIdx)
{
case 0:
_current = new Models.Stash() { SHA = line };
_stashes.Add(_current);
break;
case 1:
_current.Time = ulong.Parse(line);
break;
case 2:
_current.Name = line;
break;
case 3:
_current.Message = line;
break;
2021-04-29 05:05:55 -07:00
}
_nextLineIdx++;
if (_nextLineIdx > 3)
_nextLineIdx = 0;
2021-04-29 05:05:55 -07:00
}
private readonly List<Models.Stash> _stashes = new List<Models.Stash>();
private Models.Stash _current = null;
private int _nextLineIdx = 0;
2021-04-29 05:05:55 -07:00
}
}