* Code refactoring
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful

* Change method name
This commit is contained in:
2026-01-23 11:59:30 +01:00
parent 02664443b9
commit 58277268e3
2 changed files with 7 additions and 9 deletions

View File

@@ -61,19 +61,17 @@ public class GiteaService : IGiteaService
public async Task<(bool Status, string Response)> SendRequestAsync(GiteaConfiguration configuration, public async Task<(bool Status, string Response)> SendRequestAsync(GiteaConfiguration configuration,
string endpoint, HttpContent content) string endpoint, HttpContent content)
{ {
if (configuration == null) throw new ArgumentNullException(nameof(configuration)); ArgumentNullException.ThrowIfNull(configuration);
ArgumentNullException.ThrowIfNull(content);
if (string.IsNullOrEmpty(endpoint)) throw new ArgumentException("Endpoint cannot be null or empty.", nameof(endpoint)); if (string.IsNullOrEmpty(endpoint)) throw new ArgumentException("Endpoint cannot be null or empty.", nameof(endpoint));
if (content == null) throw new ArgumentNullException(nameof(content));
var requestUrl = $"{configuration.Url}/{endpoint}"; var requestUrl = $"{configuration.Url}/{endpoint}";
using var request = new HttpRequestMessage(HttpMethod.Post, requestUrl) using var request = new HttpRequestMessage(HttpMethod.Post, requestUrl);
{ request.Content = content;
Content = content
};
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("token", configuration.ApiToken); request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("token", configuration.ApiToken);
// Content-Type header should be set by the HttpContent automatically, avoid setting it manually here.
try try
{ {
var giteaResponse = await HttpClient.SendAsync(request); var giteaResponse = await HttpClient.SendAsync(request);

View File

@@ -5,7 +5,7 @@ namespace Services.Gitea;
public interface IGiteaService public interface IGiteaService
{ {
RepositoryApi CreateGiteaClientAsync(GiteaConfiguration configuration); RepositoryApi CreateGiteaClient(GiteaConfiguration configuration);
Task<List<Commit>> GetLastCommitsAsync(RepositoryApi repositoryApi, GiteaConfiguration configuration, int limit); Task<List<Commit>> GetLastCommitsAsync(RepositoryApi repositoryApi, GiteaConfiguration configuration, int limit);
Task<ContentsResponse> GetFileContentAsync(RepositoryApi repositoryApi, GiteaConfiguration configuration, Task<ContentsResponse> GetFileContentAsync(RepositoryApi repositoryApi, GiteaConfiguration configuration,