Skip to content

Commit 57e1296

Browse files
committed
(#146) Extend issue with an internal number
Similar to the last commit for extending the milestone model to have a internal number, we need to do the same thing with the issue model. This is due to the fact that GitLab has both an "internal" and "public" Id for the issue.
1 parent cb5e1e3 commit 57e1296

File tree

8 files changed

+15
-10
lines changed

8 files changed

+15
-10
lines changed

src/GitReleaseManager.Core.Tests/Provider/GitHubProviderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class GitHubProviderTests
4646
private const bool SKIP_PRERELEASES = false;
4747

4848
private readonly Release _release = new Release { Id = RELEASE_ID };
49-
private readonly Issue _issue = new Issue { Number = ISSUE_NUMBER };
49+
private readonly Issue _issue = new Issue { PublicNumber = ISSUE_NUMBER };
5050
private readonly Milestone _milestone = new Milestone { PublicNumber = MILESTONE_PUBLIC_NUMBER, InternalNumber = MILESTONE_INTERNAL_NUMBER };
5151
private readonly Label _label = new Label { Name = LABEL_NAME };
5252
private readonly ReleaseAsset _asset = new ReleaseAsset { Id = ASSET_ID };

src/GitReleaseManager.Core/MappingProfiles/GitHubProfile.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ public class GitHubProfile : Profile
77
{
88
public GitHubProfile()
99
{
10-
CreateMap<Model.Issue, Octokit.Issue>().ReverseMap();
10+
CreateMap<Octokit.Issue, Model.Issue>()
11+
.ForMember(dest => dest.PublicNumber, act => act.MapFrom(src => src.Number))
12+
.ForMember(dest => dest.InternalNumber, act => act.MapFrom(src => src.Id))
13+
.ReverseMap();
1114
CreateMap<Model.IssueComment, Octokit.IssueComment>().ReverseMap();
1215
CreateMap<Model.ItemState, Octokit.ItemState>().ReverseMap();
1316
CreateMap<Model.ItemStateFilter, Octokit.ItemStateFilter>().ReverseMap();

src/GitReleaseManager.Core/Model/Issue.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ public sealed class Issue
66
{
77
public string Title { get; set; }
88

9-
public int Number { get; set; }
9+
public int InternalNumber { get; set; }
10+
11+
public int PublicNumber { get; set; }
1012

1113
public string HtmlUrl { get; set; }
1214

src/GitReleaseManager.Core/Provider/GitHubProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public Task CreateIssueCommentAsync(string owner, string repository, Issue issue
8989
{
9090
return ExecuteAsync(async () =>
9191
{
92-
await _gitHubClient.Issue.Comment.Create(owner, repository, issue.Number, comment).ConfigureAwait(false);
92+
await _gitHubClient.Issue.Comment.Create(owner, repository, issue.PublicNumber, comment).ConfigureAwait(false);
9393
});
9494
}
9595

@@ -132,7 +132,7 @@ public Task<IEnumerable<IssueComment>> GetIssueCommentsAsync(string owner, strin
132132
do
133133
{
134134
var options = GetApiOptions(startPage);
135-
results = await _gitHubClient.Issue.Comment.GetAllForIssue(owner, repository, issue.Number, options).ConfigureAwait(false);
135+
results = await _gitHubClient.Issue.Comment.GetAllForIssue(owner, repository, issue.PublicNumber, options).ConfigureAwait(false);
136136

137137
comments.AddRange(results);
138138
startPage++;

src/GitReleaseManager.Core/ReleaseNotes/ReleaseNotesBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ private Dictionary<string, List<Issue>> GetIssuesDict(List<Issue> issues)
106106
.Where(o => issueLabels.Any(il => string.Equals(il, o.Label, StringComparison.OrdinalIgnoreCase)))
107107
.GroupBy(o => o.Label, o => o.Issue)
108108
.OrderBy(o => o.Key)
109-
.ToDictionary(o => GetValidLabel(o.Key, o.Count()), o => o.OrderBy(issue => issue.Number).ToList());
109+
.ToDictionary(o => GetValidLabel(o.Key, o.Count()), o => o.OrderBy(issue => issue.PublicNumber).ToList());
110110

111111
return issuesByLabel;
112112
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
- [__#{{ issue.number }}__]({{ issue.html_url }}) {{ issue.title }}
1+
- [__#{{ issue.public_number }}__]({{ issue.html_url }}) {{ issue.title }}

src/GitReleaseManager.Core/VcsService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,15 +395,15 @@ private async Task AddIssueCommentsAsync(string owner, string repository, Milest
395395
}
396396
catch (ForbiddenException)
397397
{
398-
_logger.Error("Unable to add comment to issue #{IssueNumber}. Insufficient permissions.", issue.Number);
398+
_logger.Error("Unable to add comment to issue #{IssueNumber}. Insufficient permissions.", issue.PublicNumber);
399399
break;
400400
}
401401
}
402402
}
403403

404404
private async Task<bool> CommentsIncludeStringAsync(string owner, string repository, Issue issue, string comment)
405405
{
406-
_logger.Verbose("Finding issue comment created by GitReleaseManager for issue #{IssueNumber}", issue.Number);
406+
_logger.Verbose("Finding issue comment created by GitReleaseManager for issue #{IssueNumber}", issue.PublicNumber);
407407
var issueComments = await _vcsProvider.GetIssueCommentsAsync(owner, repository, issue).ConfigureAwait(false);
408408

409409
return issueComments.Any(c => c.Body.Contains(comment));

src/GitReleaseManager.Tests/ReleaseNotesBuilderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ private static Issue CreateIssue(int number, params string[] labels)
263263
{
264264
return new Issue
265265
{
266-
Number = number,
266+
PublicNumber = number,
267267
Labels = labels.Select(l => new Label { Name = l }).ToList(),
268268
HtmlUrl = "http://example.com/" + number,
269269
Title = "Issue " + number,

0 commit comments

Comments
 (0)