some work
This commit is contained in:
@@ -21,7 +21,7 @@ internal class GitLabRepoWorkspace(GitLabRepoWorkspaceConfig config) : IWorkspac
|
||||
{
|
||||
InstallInfos = InstallInfos.Parse(await GetContent(ConfigX.FileLocationInstallJson));
|
||||
UpdateInfos = UpdateInfos.Parse(await GetContent(ConfigX.FileLocationUpdateJson));
|
||||
ConfigX.InstanceUrl = (await Gitlab.Projects.GetByIdAsync((int)ConfigX.RepoId, new())).NameWithNamespace;
|
||||
ConfigX.RepoName = (await Gitlab.Projects.GetByIdAsync((int)ConfigX.RepoId, new())).Name;
|
||||
return InstallInfos != null && UpdateInfos != null;
|
||||
}
|
||||
|
||||
@@ -38,27 +38,25 @@ internal class GitLabRepoWorkspace(GitLabRepoWorkspaceConfig config) : IWorkspac
|
||||
|
||||
private async Task<string> GetContent(string path)
|
||||
{
|
||||
var pathUrl = UrlEncoder.Default.Encode(path);
|
||||
var repoId = new ProjectId(ConfigX.RepoId);
|
||||
var repo = Gitlab.GetRepository(repoId);
|
||||
var data = await repo.Files.GetAsync(pathUrl, ConfigX.RepoBranche);
|
||||
var data = await repo.Files.GetAsync(path, ConfigX.RepoBranche);
|
||||
return data.DecodedContent;
|
||||
}
|
||||
|
||||
private Task<bool> SaveContent(string path, string content)
|
||||
{
|
||||
var pathUrl = UrlEncoder.Default.Encode(path);
|
||||
var repoId = new ProjectId(ConfigX.RepoId);
|
||||
var repo = Gitlab.GetRepository(repoId);
|
||||
var update = new FileUpsert
|
||||
{
|
||||
Branch = ConfigX.RepoBranche,
|
||||
CommitMessage = "update " + Path.GetFileName(pathUrl),
|
||||
CommitMessage = "update " + Path.GetFileName(path),
|
||||
RawContent = content,
|
||||
Path = pathUrl,
|
||||
Path = path,
|
||||
};
|
||||
|
||||
if (repo.Files.FileExists(pathUrl, ConfigX.RepoBranche))
|
||||
if (repo.Files.FileExists(path, ConfigX.RepoBranche))
|
||||
repo.Files.Update(update);
|
||||
else
|
||||
repo.Files.Create(update);
|
||||
|
||||
Reference in New Issue
Block a user