Skip to content

Commit

Permalink
formatted the code
Browse files Browse the repository at this point in the history
  • Loading branch information
arturcic committed Jan 9, 2025
1 parent 575e9ea commit 8d7f7ee
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
using NotFoundException = GitReleaseManager.Core.Exceptions.NotFoundException;
using RateLimit = GitReleaseManager.Core.Model.RateLimit;
using Release = GitReleaseManager.Core.Model.Release;
using ReleaseAsset= GitReleaseManager.Core.Model.ReleaseAsset;
using ReleaseAsset = GitReleaseManager.Core.Model.ReleaseAsset;
using ReleaseAssetUpload = GitReleaseManager.Core.Model.ReleaseAssetUpload;

namespace GitReleaseManager.Core.Tests.Provider
Expand Down
3 changes: 1 addition & 2 deletions src/GitReleaseManager.Core.Tests/VcsServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,7 @@ public async Task Should_Create_Release_From_Milestone_With_Assets()
null,
_assets,
false,
null
).ConfigureAwait(false);
null).ConfigureAwait(false);
result.ShouldBeSameAs(release);

await _releaseNotesBuilder.Received(1).BuildReleaseNotesAsync(OWNER, REPOSITORY, MILESTONE_TITLE, ReleaseTemplates.DEFAULT_NAME).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ protected InvalidIssuesException(
{
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ public GitLabProfile()
.ReverseMap();
}
}
}
}
2 changes: 1 addition & 1 deletion src/GitReleaseManager.Core/Model/VcsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ public enum VcsProvider
GitHub = 0,
GitLab = 1,
}
}
}
3 changes: 1 addition & 2 deletions src/GitReleaseManager.Core/Options/BaseSubOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ protected BaseSubOptions()
{
var ciEnvironmentVariable = Environment.GetEnvironmentVariable("CI");

bool isCiSystem;
if (!string.IsNullOrEmpty(ciEnvironmentVariable) && bool.TryParse(ciEnvironmentVariable, out isCiSystem))
if (!string.IsNullOrEmpty(ciEnvironmentVariable) && bool.TryParse(ciEnvironmentVariable, out bool isCiSystem))
{
IsCISystem = isCiSystem;
}
Expand Down
52 changes: 26 additions & 26 deletions src/GitReleaseManager.Core/Provider/GitHubProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ public GitHubProvider(IGitHubClient gitHubClient, IMapper mapper)

public Task DeleteAssetAsync(string owner, string repository, ReleaseAsset asset)
{
return ExecuteAsync(async () =>
return GitHubProvider.ExecuteAsync(async () =>
{
await _gitHubClient.Repository.Release.DeleteAsset(owner, repository, asset.Id).ConfigureAwait(false);
});
}

public Task UploadAssetAsync(Release release, ReleaseAssetUpload releaseAssetUpload)
{
return ExecuteAsync(async () =>
return GitHubProvider.ExecuteAsync(async () =>
{
var octokitRelease = _mapper.Map<Octokit.Release>(release);
var octokitReleaseAssetUpload = _mapper.Map<Octokit.ReleaseAssetUpload>(releaseAssetUpload);
Expand All @@ -56,7 +56,7 @@ public Task UploadAssetAsync(Release release, ReleaseAssetUpload releaseAssetUpl

public Task<int> GetCommitsCountAsync(string owner, string repository, string @base, string head)
{
return ExecuteAsync(async () =>
return GitHubProvider.ExecuteAsync(async () =>
{
try
{
Expand Down Expand Up @@ -87,15 +87,15 @@ public string GetCommitsUrl(string owner, string repository, string head, string

public Task CreateIssueCommentAsync(string owner, string repository, Issue issue, string comment)
{
return ExecuteAsync(async () =>
return GitHubProvider.ExecuteAsync(async () =>
{
await _gitHubClient.Issue.Comment.Create(owner, repository, issue.PublicNumber, comment).ConfigureAwait(false);
});
}

public Task<IEnumerable<Issue>> GetIssuesAsync(string owner, string repository, Milestone milestone, ItemStateFilter itemStateFilter = ItemStateFilter.All)
{
return ExecuteAsync(async () =>
return GitHubProvider.ExecuteAsync(async () =>
{
var openIssueRequest = new RepositoryIssueRequest
{
Expand All @@ -109,7 +109,7 @@ public Task<IEnumerable<Issue>> GetIssuesAsync(string owner, string repository,

do
{
var options = GetApiOptions(startPage);
var options = GitHubProvider.GetApiOptions(startPage);
results = await _gitHubClient.Issue.GetAllForRepository(owner, repository, openIssueRequest, options).ConfigureAwait(false);

issues.AddRange(results);
Expand All @@ -123,15 +123,15 @@ public Task<IEnumerable<Issue>> GetIssuesAsync(string owner, string repository,

public Task<IEnumerable<IssueComment>> GetIssueCommentsAsync(string owner, string repository, Issue issue)
{
return ExecuteAsync(async () =>
return GitHubProvider.ExecuteAsync(async () =>
{
var startPage = 1;
var comments = new List<Octokit.IssueComment>();
IReadOnlyList<Octokit.IssueComment> results;

do
{
var options = GetApiOptions(startPage);
var options = GitHubProvider.GetApiOptions(startPage);
results = await _gitHubClient.Issue.Comment.GetAllForIssue(owner, repository, issue.PublicNumber, options).ConfigureAwait(false);

comments.AddRange(results);
Expand All @@ -145,7 +145,7 @@ public Task<IEnumerable<IssueComment>> GetIssueCommentsAsync(string owner, strin

public Task CreateLabelAsync(string owner, string repository, Label label)
{
return ExecuteAsync(async () =>
return GitHubProvider.ExecuteAsync(async () =>
{
var newLabel = _mapper.Map<NewLabel>(label);

Expand All @@ -155,23 +155,23 @@ public Task CreateLabelAsync(string owner, string repository, Label label)

public Task DeleteLabelAsync(string owner, string repository, Label label)
{
return ExecuteAsync(async () =>
return GitHubProvider.ExecuteAsync(async () =>
{
await _gitHubClient.Issue.Labels.Delete(owner, repository, label.Name).ConfigureAwait(false);
});
}

public Task<IEnumerable<Label>> GetLabelsAsync(string owner, string repository)
{
return ExecuteAsync(async () =>
return GitHubProvider.ExecuteAsync(async () =>
{
var startPage = 1;
var labels = new List<Octokit.Label>();
IReadOnlyList<Octokit.Label> results;

do
{
var options = GetApiOptions(startPage);
var options = GitHubProvider.GetApiOptions(startPage);
results = await _gitHubClient.Issue.Labels.GetAllForRepository(owner, repository, options).ConfigureAwait(false);

labels.AddRange(results);
Expand All @@ -185,7 +185,7 @@ public Task<IEnumerable<Label>> GetLabelsAsync(string owner, string repository)

public Task<Milestone> GetMilestoneAsync(string owner, string repository, string milestoneTitle, ItemStateFilter itemStateFilter = ItemStateFilter.All)
{
return ExecuteAsync(async () =>
return GitHubProvider.ExecuteAsync(async () =>
{
var milestones = await GetMilestonesAsync(owner, repository, itemStateFilter).ConfigureAwait(false);
var foundMilestone = milestones.FirstOrDefault(m => m.Title == milestoneTitle);
Expand All @@ -201,7 +201,7 @@ public Task<Milestone> GetMilestoneAsync(string owner, string repository, string

public Task<IEnumerable<Milestone>> GetMilestonesAsync(string owner, string repository, ItemStateFilter itemStateFilter = ItemStateFilter.All)
{
return ExecuteAsync(async () =>
return GitHubProvider.ExecuteAsync(async () =>
{
var request = new MilestoneRequest { State = (Octokit.ItemStateFilter)itemStateFilter };

Expand All @@ -211,7 +211,7 @@ public Task<IEnumerable<Milestone>> GetMilestonesAsync(string owner, string repo

do
{
var options = GetApiOptions(startPage);
var options = GitHubProvider.GetApiOptions(startPage);
results = await _gitHubClient.Issue.Milestone.GetAllForRepository(owner, repository, request, options).ConfigureAwait(false);

milestones.AddRange(results);
Expand All @@ -225,7 +225,7 @@ public Task<IEnumerable<Milestone>> GetMilestonesAsync(string owner, string repo

public Task SetMilestoneStateAsync(string owner, string repository, Milestone milestone, ItemState itemState)
{
return ExecuteAsync(async () =>
return GitHubProvider.ExecuteAsync(async () =>
{
var update = new MilestoneUpdate { State = (Octokit.ItemState)itemState };
await _gitHubClient.Issue.Milestone.Update(owner, repository, milestone.PublicNumber, update).ConfigureAwait(false);
Expand All @@ -234,7 +234,7 @@ public Task SetMilestoneStateAsync(string owner, string repository, Milestone mi

public Task<Release> CreateReleaseAsync(string owner, string repository, Release release)
{
return ExecuteAsync(async () =>
return GitHubProvider.ExecuteAsync(async () =>
{
var newRelease = _mapper.Map<NewRelease>(release);
var octokitRelease = await _gitHubClient.Repository.Release.Create(owner, repository, newRelease).ConfigureAwait(false);
Expand All @@ -245,15 +245,15 @@ public Task<Release> CreateReleaseAsync(string owner, string repository, Release

public Task DeleteReleaseAsync(string owner, string repository, Release release)
{
return ExecuteAsync(async () =>
return GitHubProvider.ExecuteAsync(async () =>
{
await _gitHubClient.Repository.Release.Delete(owner, repository, release.Id).ConfigureAwait(false);
});
}

public Task<Release> GetReleaseAsync(string owner, string repository, string tagName)
{
return ExecuteAsync(async () =>
return GitHubProvider.ExecuteAsync(async () =>
{
// This method wants to return a single Release, that has the tagName that is requested.
// The obvious thing to do here would be to use Repository.Release.Get, however, this doesn't
Expand All @@ -270,15 +270,15 @@ public Task<Release> GetReleaseAsync(string owner, string repository, string tag

public Task<IEnumerable<Release>> GetReleasesAsync(string owner, string repository, bool skipPrereleases)
{
return ExecuteAsync(async () =>
return GitHubProvider.ExecuteAsync(async () =>
{
var startPage = 1;
var releases = new List<Octokit.Release>();
IReadOnlyList<Octokit.Release> results;

do
{
var options = GetApiOptions(startPage);
var options = GitHubProvider.GetApiOptions(startPage);
results = await _gitHubClient.Repository.Release.GetAll(owner, repository, options).ConfigureAwait(false);

if (skipPrereleases)
Expand All @@ -302,7 +302,7 @@ public Task<IEnumerable<Release>> GetReleasesAsync(string owner, string reposito

public Task PublishReleaseAsync(string owner, string repository, string tagName, Release release)
{
return ExecuteAsync(async () =>
return GitHubProvider.ExecuteAsync(async () =>
{
var update = new ReleaseUpdate
{
Expand All @@ -316,7 +316,7 @@ public Task PublishReleaseAsync(string owner, string repository, string tagName,

public Task UpdateReleaseAsync(string owner, string repository, Release release)
{
return ExecuteAsync(async () =>
return GitHubProvider.ExecuteAsync(async () =>
{
var update = new ReleaseUpdate
{
Expand Down Expand Up @@ -356,7 +356,7 @@ public string GetIssueType(Issue issue)
return issue.IsPullRequest ? "Pull Request" : "Issue";
}

private async Task ExecuteAsync(Func<Task> action)
private static async Task ExecuteAsync(Func<Task> action)
{
try
{
Expand All @@ -376,7 +376,7 @@ private async Task ExecuteAsync(Func<Task> action)
}
}

private async Task<T> ExecuteAsync<T>(Func<Task<T>> action)
private static async Task<T> ExecuteAsync<T>(Func<Task<T>> action)
{
try
{
Expand All @@ -396,7 +396,7 @@ private async Task<T> ExecuteAsync<T>(Func<Task<T>> action)
}
}

private ApiOptions GetApiOptions(int startPage = 1, int pageSize = 100, int pageCount = 1)
private static ApiOptions GetApiOptions(int startPage = 1, int pageSize = 100, int pageCount = 1)
{
return new ApiOptions
{
Expand Down
6 changes: 3 additions & 3 deletions src/GitReleaseManager.Core/Provider/GitLabProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ private long GetGitLabProjectId(string owner, string repository)
return _projectId.Value;
}

private async Task ExecuteAsync(Func<Task> action)
private static async Task ExecuteAsync(Func<Task> action)
{
try
{
Expand All @@ -421,7 +421,7 @@ private async Task ExecuteAsync(Func<Task> action)
}
}

private async Task<T> ExecuteAsync<T>(Func<Task<T>> action)
private static async Task<T> ExecuteAsync<T>(Func<Task<T>> action)
{
try
{
Expand All @@ -437,4 +437,4 @@ private async Task<T> ExecuteAsync<T>(Func<Task<T>> action)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ private string GetValidLabel(string label, int issuesCount)

foreach (var issueLabel in issue.Labels)
{
includedIssuesCount += _configuration.IssueLabelsInclude.Count(issueToInclude => issueLabel.Name.ToUpperInvariant() == issueToInclude.ToUpperInvariant());
includedIssuesCount += _configuration.IssueLabelsInclude.Count(issueToInclude => string.Equals(issueLabel.Name, issueToInclude, StringComparison.InvariantCultureIgnoreCase));

isExcluded = isExcluded || _configuration.IssueLabelsExclude.Any(issueToExclude => issueLabel.Name.ToUpperInvariant() == issueToExclude.ToUpperInvariant());
isExcluded = isExcluded || _configuration.IssueLabelsExclude.Any(issueToExclude => string.Equals(issueLabel.Name, issueToExclude, StringComparison.InvariantCultureIgnoreCase));
}

if (isExcluded)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ public async Task Should_Get_Commits_Count()
// result.ShouldBeGreaterThan(0);
}
}
}
}

0 comments on commit 8d7f7ee

Please sign in to comment.