-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement support for Gitea #264
Closed
Closed
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b0f979b
Add project Gitea
belidzs eb4ff06
Reference project Gitea
belidzs d6cb022
Implement CreateLabels in GiteaProvider
belidzs 82eec9b
Add --provider and --providerUrl options to BaseVcsOptions
belidzs 40b2071
Use GiteaProvider in CLI
belidzs b3934a2
BaseVcsSubOptions HelpText fix
belidzs b9e8689
Implement CloseMilestone() in GiteaProvider
belidzs 58721a2
Add comments to GiteaProvider
belidzs 68c2fc2
Temporarily include Gitea in the solution as a git submodule
belidzs a6447c5
WIP Implement abstract class VcsProvider
belidzs 1f53737
IssueApi refactoring
belidzs 293164c
Rename VcsProvider, refactor async method names
belidzs 3e4ddaa
Rename CreateLabelsAsync() to CreateDefaultLabelsAsync()
belidzs 943ab00
WIP Refactor GitHubProvider to use inherited methods
belidzs ca8785e
WIP Implement CloseAndCommentMilestoneAsync() in base class
belidzs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "Source/Gitea"] | ||
path = Source/Gitea | ||
url = [email protected]:belidzs/Gitea.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
namespace GitReleaseManager.Core | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using GitReleaseManager.Core.Configuration; | ||
using GitReleaseManager.Core.Model; | ||
using Serilog; | ||
|
||
public abstract class BaseVcsProvider : IVcsProvider | ||
{ | ||
public BaseVcsProvider(Config configuration, ILogger logger) | ||
{ | ||
Configuration = configuration; | ||
Logger = logger; | ||
} | ||
|
||
protected Config Configuration { get; } | ||
|
||
protected ILogger Logger { get; } | ||
|
||
public abstract Task AddAssets(string owner, string repository, string tagName, IList<string> assets); | ||
|
||
public abstract Task CloseMilestoneAsync(string owner, string repository, string milestoneTitle); | ||
|
||
public abstract Task<Release> CreateReleaseFromInputFile(string owner, string repository, string name, string inputFilePath, string targetCommitish, IList<string> assets, bool prerelease); | ||
|
||
public abstract Task<Release> CreateReleaseFromMilestone(string owner, string repository, string milestone, string releaseName, string targetCommitish, IList<string> assets, bool prerelease); | ||
|
||
public abstract Task DiscardRelease(string owner, string repository, string name); | ||
|
||
public abstract Task<string> ExportReleases(string owner, string repository, string tagName); | ||
|
||
public abstract string GetCommitsLink(string user, string repository, Milestone milestone, Milestone previousMilestone); | ||
|
||
public abstract Task<List<Issue>> GetIssuesAsync(Milestone targetMilestone); | ||
|
||
public abstract Task<int> GetNumberOfCommitsBetween(Milestone previousMilestone, Milestone currentMilestone, string user, string repository); | ||
|
||
public abstract Task<ReadOnlyCollection<Milestone>> GetReadOnlyMilestonesAsync(string user, string repository); | ||
|
||
public abstract Task<List<Release>> GetReleasesAsync(string user, string repository); | ||
|
||
public abstract Task<Release> GetSpecificRelease(string tagName, string user, string repository); | ||
|
||
public abstract Task OpenMilestone(string owner, string repository, string milestoneTitle); | ||
|
||
public abstract Task PublishRelease(string owner, string repository, string tagName); | ||
|
||
public virtual async Task CreateLabelsAsync(string owner, string repository) | ||
{ | ||
if (Configuration.Labels.Any()) | ||
{ | ||
Logger.Verbose("Removing existing labels"); | ||
await DeleteExistingLabelsAsync(owner, repository).ConfigureAwait(false); | ||
Logger.Verbose("Creating new standard labels"); | ||
var newLabelTasks = new List<Task>(); | ||
foreach (var label in Configuration.Labels) | ||
{ | ||
newLabelTasks.Add(CreateLabelAsync(owner, repository, label)); | ||
} | ||
|
||
await Task.WhenAll(newLabelTasks).ConfigureAwait(false); | ||
} | ||
else | ||
{ | ||
Logger.Warning("No labels defined"); | ||
} | ||
} | ||
|
||
protected abstract Task DeleteExistingLabelsAsync(string owner, string repository); | ||
|
||
protected abstract Task CreateLabelAsync(string owner, string repository, LabelConfig label); | ||
|
||
protected abstract Task<List<string>> GetCommentsForIssueAsync(string owner, string repository, long index); | ||
|
||
|
||
protected virtual async Task<bool> DoesAnyCommentIncludeStringAsync(string owner, string repository, long index, string comment) | ||
{ | ||
Logger.Verbose("Finding issue comment created by GitReleaseManager for issue #{IssueNumber}", index); | ||
var issueComments = await GetCommentsForIssueAsync(owner, repository, index).ConfigureAwait(false); | ||
return issueComments.Any(c => c.Contains(comment)); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an example of a public default implementation of an interface method which calls for two abstract protected methods.
It's completely possible that it is somehow anti-pattern, however it reduces redundant code quite a bit