2024-06-04 20:46:31 -07:00
|
|
|
|
using System.Collections.Generic;
|
2021-04-29 05:05:55 -07:00
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
namespace SourceGit.Commands
|
|
|
|
|
{
|
2024-06-04 20:46:31 -07:00
|
|
|
|
public class QueryStashes : Command
|
2024-03-17 18:37:06 -07:00
|
|
|
|
{
|
|
|
|
|
public QueryStashes(string repo)
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
WorkingDirectory = repo;
|
|
|
|
|
Context = repo;
|
2024-06-04 20:46:31 -07:00
|
|
|
|
Args = "stash list --pretty=format:%H%n%ct%n%gd%n%s";
|
2021-04-29 05:05:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public List<Models.Stash> Result()
|
|
|
|
|
{
|
2021-04-29 05:05:55 -07:00
|
|
|
|
Exec();
|
2024-02-05 23:08:37 -08:00
|
|
|
|
return _stashes;
|
2021-04-29 05:05:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
protected override void OnReadline(string line)
|
|
|
|
|
{
|
2024-06-04 20:46:31 -07:00
|
|
|
|
switch (_nextLineIdx)
|
2024-03-17 18:37:06 -07:00
|
|
|
|
{
|
2024-06-04 20:46:31 -07:00
|
|
|
|
case 0:
|
|
|
|
|
_current = new Models.Stash() { SHA = line };
|
2024-03-31 01:54:29 -07:00
|
|
|
|
_stashes.Add(_current);
|
2024-06-04 20:46:31 -07:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2024-06-04 20:46:31 -07:00
|
|
|
|
_nextLineIdx++;
|
|
|
|
|
if (_nextLineIdx > 3)
|
|
|
|
|
_nextLineIdx = 0;
|
2021-04-29 05:05:55 -07:00
|
|
|
|
}
|
2024-02-05 23:08:37 -08:00
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
private readonly List<Models.Stash> _stashes = new List<Models.Stash>();
|
2024-02-05 23:08:37 -08:00
|
|
|
|
private Models.Stash _current = null;
|
2024-06-04 20:46:31 -07:00
|
|
|
|
private int _nextLineIdx = 0;
|
2021-04-29 05:05:55 -07:00
|
|
|
|
}
|
2024-03-31 01:54:29 -07:00
|
|
|
|
}
|