* Added method to get all branches from repo
Some checks failed
ci/woodpecker/push/push_to_repo Pipeline failed
Some checks failed
ci/woodpecker/push/push_to_repo Pipeline failed
This commit is contained in:
@@ -41,16 +41,28 @@ public class GiteaService : IGiteaService
|
|||||||
|
|
||||||
public async Task<Commit?> GetLastCommitAsync(RepositoryApi repositoryApi, GiteaConfiguration configuration)
|
public async Task<Commit?> GetLastCommitAsync(RepositoryApi repositoryApi, GiteaConfiguration configuration)
|
||||||
{
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(repositoryApi);
|
||||||
|
ArgumentNullException.ThrowIfNull(configuration);
|
||||||
|
|
||||||
var lastCommit = await GetLastCommitsAsync(repositoryApi, configuration, 1);
|
var lastCommit = await GetLastCommitsAsync(repositoryApi, configuration, 1);
|
||||||
return lastCommit.FirstOrDefault();
|
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,
|
public async Task<ContentsResponse> GetFileContentAsync(RepositoryApi repositoryApi,
|
||||||
GiteaConfiguration configuration,
|
GiteaConfiguration configuration,
|
||||||
string filename)
|
string filename)
|
||||||
{
|
{
|
||||||
if (repositoryApi == null) throw new ArgumentNullException(nameof(repositoryApi));
|
ArgumentNullException.ThrowIfNull(repositoryApi);
|
||||||
if (configuration == null) throw new ArgumentNullException(nameof(configuration));
|
ArgumentNullException.ThrowIfNull(configuration);
|
||||||
if (string.IsNullOrEmpty(filename)) throw new ArgumentException("Filename cannot be null or empty.", nameof(filename));
|
if (string.IsNullOrEmpty(filename)) throw new ArgumentException("Filename cannot be null or empty.", nameof(filename));
|
||||||
|
|
||||||
var repoGetContentsAsync =
|
var repoGetContentsAsync =
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ public interface IGiteaService
|
|||||||
|
|
||||||
Task<Commit?> GetLastCommitAsync(RepositoryApi repositoryApi, GiteaConfiguration configuration);
|
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,
|
Task<(bool Status, string Response)> SendRequestAsync(GiteaConfiguration configuration, string endpoint,
|
||||||
HttpContent content);
|
HttpContent content);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user