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-08-08 06:11:10 -07:00
|
|
|
|
public List<Models.Submodule> Result()
|
2024-03-17 18:37:06 -07:00
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
Exec();
|
2024-08-08 06:11:10 -07:00
|
|
|
|
new UpdateSubmoduleStatus(WorkingDirectory, _submodules).Result();
|
2024-02-05 23:08:37 -08:00
|
|
|
|
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-08-08 06:11:10 -07:00
|
|
|
|
_submodules.Add(new Models.Submodule() { Path = match.Groups[1].Value });
|
2024-02-20 20:26:09 -08:00
|
|
|
|
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-08-08 06:11:10 -07:00
|
|
|
|
_submodules.Add(new Models.Submodule() { Path = match.Groups[1].Value });
|
2024-02-20 20:26:09 -08:00
|
|
|
|
}
|
2024-02-05 23:08:37 -08:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 06:11:10 -07:00
|
|
|
|
private readonly List<Models.Submodule> _submodules = new List<Models.Submodule>();
|
2024-02-05 23:08:37 -08:00
|
|
|
|
}
|
2024-03-31 01:54:29 -07:00
|
|
|
|
}
|