* Added method to get all branches from repo
Some checks failed
ci/woodpecker/push/push_to_repo Pipeline failed

This commit is contained in:
2026-01-23 14:31:23 +01:00
parent d84efc9509
commit d44c393614
2 changed files with 16 additions and 2 deletions

View File

@@ -41,16 +41,28 @@ public class GiteaService : IGiteaService
public async Task<Commit?> GetLastCommitAsync(RepositoryApi repositoryApi, GiteaConfiguration configuration)
{
ArgumentNullException.ThrowIfNull(repositoryApi);
ArgumentNullException.ThrowIfNull(configuration);
var lastCommit = await GetLastCommitsAsync(repositoryApi, configuration, 1);
return lastCommit.FirstOrDefault();
}
public async Task<List<Branch>> GetAllBranchesAsync(RepositoryApi repositoryApi, GiteaConfiguration configuration)
{
ArgumentNullException.ThrowIfNull(repositoryApi);
ArgumentNullException.ThrowIfNull(configuration);
var branches = await repositoryApi.RepoListBranchesAsync(configuration.Owner, configuration.Repository);
return branches;
}
public async Task<ContentsResponse> GetFileContentAsync(RepositoryApi repositoryApi,
GiteaConfiguration configuration,
string filename)
{
if (repositoryApi == null) throw new ArgumentNullException(nameof(repositoryApi));
if (configuration == null) throw new ArgumentNullException(nameof(configuration));
ArgumentNullException.ThrowIfNull(repositoryApi);
ArgumentNullException.ThrowIfNull(configuration);
if (string.IsNullOrEmpty(filename)) throw new ArgumentException("Filename cannot be null or empty.", nameof(filename));
var repoGetContentsAsync =

View File

@@ -13,6 +13,8 @@ public interface IGiteaService
Task<Commit?> GetLastCommitAsync(RepositoryApi repositoryApi, GiteaConfiguration configuration);
Task<List<Branch>> GetAllBranchesAsync(RepositoryApi repositoryApi, GiteaConfiguration configuration);
Task<(bool Status, string Response)> SendRequestAsync(GiteaConfiguration configuration, string endpoint,
HttpContent content);
}