2024-02-05 23:08:37 -08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
namespace SourceGit.Commands
|
|
|
|
|
{
|
|
|
|
|
public partial class QuerySubmodules : Command
|
|
|
|
|
{
|
2024-03-16 02:09:27 -07:00
|
|
|
|
[GeneratedRegex(@"^[\-\+ ][0-9a-f]+\s(.*)\s\(.*\)$")]
|
|
|
|
|
private static partial Regex REG_FORMAT1();
|
|
|
|
|
[GeneratedRegex(@"^[\-\+ ][0-9a-f]+\s(.*)$")]
|
|
|
|
|
private static partial Regex REG_FORMAT2();
|
2024-02-05 23:08:37 -08:00
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public QuerySubmodules(string repo)
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
WorkingDirectory = repo;
|
|
|
|
|
Context = repo;
|
|
|
|
|
Args = "submodule status";
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public List<string> Result()
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
Exec();
|
|
|
|
|
return _submodules;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
protected override void OnReadline(string line)
|
|
|
|
|
{
|
2024-03-16 02:09:27 -07:00
|
|
|
|
var match = REG_FORMAT1().Match(line);
|
2024-03-17 18:37:06 -07:00
|
|
|
|
if (match.Success)
|
|
|
|
|
{
|
2024-02-20 20:26:09 -08:00
|
|
|
|
_submodules.Add(match.Groups[1].Value);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-03-17 18:37:06 -07:00
|
|
|
|
|
2024-03-16 02:09:27 -07:00
|
|
|
|
match = REG_FORMAT2().Match(line);
|
2024-03-17 18:37:06 -07:00
|
|
|
|
if (match.Success)
|
|
|
|
|
{
|
2024-02-20 20:26:09 -08:00
|
|
|
|
_submodules.Add(match.Groups[1].Value);
|
|
|
|
|
}
|
2024-02-05 23:08:37 -08:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
private readonly List<string> _submodules = new List<string>();
|
2024-02-05 23:08:37 -08:00
|
|
|
|
}
|
2024-03-31 01:54:29 -07:00
|
|
|
|
}
|