Глобальный рефакторинг пространств имён
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using Pf2e.Scrapper.Helpers;
|
||||
|
||||
namespace Pf2e.Scrapper.Importers.Repositories;
|
||||
|
||||
/// <summary>
|
||||
/// Репозиторий, загружающий данные из GIT-источника.
|
||||
/// </summary>
|
||||
/// <param name="importer">Импортёр, использующий репозиторий.</param>
|
||||
/// <param name="url">Ссылка на GIT-репозиторий.</param>
|
||||
internal class GitRepository(AbstractImporter importer, string url)
|
||||
: AbstractImporterRepository(importer)
|
||||
{
|
||||
/// <summary>
|
||||
/// Ссылка на GIT-репозиторий.
|
||||
/// </summary>
|
||||
public string Url { get; } = url;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Update(ProcessProgress progress)
|
||||
{
|
||||
progress.Local.Reset(1);
|
||||
|
||||
if (Directory.Exists(RepositoryDirPath))
|
||||
{
|
||||
progress.Local.Start("git pull");
|
||||
|
||||
Process process = new()
|
||||
{
|
||||
StartInfo = new()
|
||||
{
|
||||
FileName = "git",
|
||||
WorkingDirectory = RepositoryDirPath,
|
||||
Arguments = "pull",
|
||||
},
|
||||
};
|
||||
process.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
progress.Local.Start("git clone");
|
||||
|
||||
Process process = new()
|
||||
{
|
||||
StartInfo = new()
|
||||
{
|
||||
FileName = "git",
|
||||
WorkingDirectory = EnvSettings.DataDirPath,
|
||||
Arguments = $"clone {Url} {Importer.Slug}",
|
||||
},
|
||||
};
|
||||
process.Start();
|
||||
}
|
||||
|
||||
progress.Local.Complete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user