forked from GitTools/GitReleaseManager
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit introduces a new GitLabProvider class, and implements the necessary methods to allow GRM to create release notes on GitLab. This is made possible by using the NGitLab library. A new option has been added to the base command, which allows settings of the --provider at the command line. The default value for this option is GitHub, so everything continues to work as it is expected to.
- Loading branch information
Showing
8 changed files
with
434 additions
and
6 deletions.
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
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
35 changes: 35 additions & 0 deletions
35
src/GitReleaseManager.Core/MappingProfiles/GitLabProfile.cs
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,35 @@ | ||
namespace GitReleaseManager.Core.MappingProfiles | ||
{ | ||
using System; | ||
using AutoMapper; | ||
using GitReleaseManager.Core.Extensions; | ||
|
||
public class GitLabProfile : Profile | ||
{ | ||
public GitLabProfile() | ||
{ | ||
CreateMap<NGitLab.Models.Milestone, Model.Milestone>() | ||
.ForMember(dest => dest.PublicNumber, act => act.MapFrom(src => src.Iid)) | ||
.ForMember(dest => dest.InternalNumber, act => act.MapFrom(src => src.Id)) | ||
.AfterMap((src, dest) => dest.Version = src.Version()); | ||
CreateMap<NGitLab.Models.ReleaseInfo, Model.Release>() | ||
.ForMember(dest => dest.Draft, act => act.MapFrom(src => src.ReleasedAt > DateTime.UtcNow)) | ||
.ForMember(dest => dest.Body, act => act.MapFrom(src => src.Description)) | ||
.ForMember(dest => dest.Assets, act => act.MapFrom(src => src.Assets.Links)) | ||
.ReverseMap(); | ||
CreateMap<NGitLab.Models.ReleaseLink, Model.ReleaseAsset>().ReverseMap(); | ||
CreateMap<NGitLab.Models.Issue, Model.Issue>() | ||
.ForMember(dest => dest.Number, act => act.MapFrom(src => src.IssueId)) | ||
.ForMember(dest => dest.HtmlUrl, act => act.MapFrom(src => src.WebUrl)) | ||
.ReverseMap(); | ||
CreateMap<string, Model.Label>().ForMember(dest => dest.Name, act => act.MapFrom(src => src)); | ||
CreateMap<Model.Release, NGitLab.Models.ReleaseCreate>() | ||
.ForMember(dest => dest.Description, act => act.MapFrom(src => src.Body)) | ||
.ForMember(dest => dest.Ref, act => act.MapFrom(src => src.TargetCommitish)) | ||
.ForMember(dest => dest.Milestones, act => act.MapFrom(src => new string[] { src.TagName })) | ||
.ForMember(dest => dest.ReleasedAt, act => act.MapFrom(src => src.Draft ? DateTime.UtcNow.AddYears(1) : DateTime.UtcNow)) | ||
.ForMember(dest => dest.Assets, act => act.Ignore()) | ||
.ReverseMap(); | ||
} | ||
} | ||
} |
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,8 @@ | ||
namespace GitReleaseManager.Core.Model | ||
{ | ||
public enum VcsProvider | ||
{ | ||
GitHub = 0, | ||
GitLab = 1, | ||
} | ||
} |
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.