Skip to content

Commit daf2b7c

Browse files
committed
(#146) Extend milestone with an internal number
Looking at the upcoming work for GitLab, it is clear that we need to extend, at the very least, the internal GRM representation. This is due to the fact that GitLab has both an "internal" and "public" Id for the milestone. It seems to be the case that the internal one, typically a higher number, is used when updating/changing a milestone, whereas the public one is used when linking to a milestone within the project. We need to use both of these, so we need to capture both of them. For something like the GitHub provider, which doesn't make this distinction, we will simply map the single Id to both the internal and public properties.
1 parent a8d17f4 commit daf2b7c

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

src/GitReleaseManager.Core/MappingProfiles/GitHubProfile.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public GitHubProfile()
2020
CreateMap<Model.Label, Octokit.NewLabel>().ReverseMap();
2121
CreateMap<Model.Milestone, Octokit.Milestone>();
2222
CreateMap<Octokit.Milestone, Model.Milestone>()
23+
.ForMember(dest => dest.PublicNumber, act => act.MapFrom(src => src.Number))
24+
.ForMember(dest => dest.InternalNumber, act => act.MapFrom(src => src.Number))
2325
.AfterMap((src, dest) => dest.Version = src.Version());
2426
}
2527
}

src/GitReleaseManager.Core/Model/Milestone.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ public sealed class Milestone
88

99
public string Description { get; set; }
1010

11-
public int Number { get; set; }
11+
public int PublicNumber { get; set; }
12+
13+
public int InternalNumber { get; set; }
1214

1315
public string HtmlUrl { get; set; }
1416

src/GitReleaseManager.IntegrationTests/GitHubProviderIntegrationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public async Task Should_Get_Milestones()
6363
var result = await _gitHubProvider.GetMilestonesAsync(OWNER, REPOSITORY).ConfigureAwait(false);
6464
result.Count().ShouldBeGreaterThan(0);
6565

66-
_milestone = result.OrderByDescending(m => m.Number).First();
66+
_milestone = result.OrderByDescending(m => m.PublicNumber).First();
6767
}
6868

6969
[Test]

src/GitReleaseManager.Tests/ReleaseNotesBuilderTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ private static Milestone CreateMilestone(string version, string description = nu
249249
{
250250
Title = version,
251251
Description = description,
252-
Number = 1,
252+
PublicNumber = 1,
253+
InternalNumber = 123,
253254
HtmlUrl = "https://github.com/gep13/FakeRepository/issues?q=milestone%3A" + version,
254255
Version = new Version(version),
255256
};

0 commit comments

Comments
 (0)