Skip to content

Commit

Permalink
(#146) Extend milestone with an internal number
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gep13 committed Nov 10, 2023
1 parent a8d17f4 commit daf2b7c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/GitReleaseManager.Core/MappingProfiles/GitHubProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public GitHubProfile()
CreateMap<Model.Label, Octokit.NewLabel>().ReverseMap();
CreateMap<Model.Milestone, Octokit.Milestone>();
CreateMap<Octokit.Milestone, Model.Milestone>()
.ForMember(dest => dest.PublicNumber, act => act.MapFrom(src => src.Number))
.ForMember(dest => dest.InternalNumber, act => act.MapFrom(src => src.Number))
.AfterMap((src, dest) => dest.Version = src.Version());
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/GitReleaseManager.Core/Model/Milestone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ public sealed class Milestone

public string Description { get; set; }

public int Number { get; set; }
public int PublicNumber { get; set; }

public int InternalNumber { get; set; }

public string HtmlUrl { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public async Task Should_Get_Milestones()
var result = await _gitHubProvider.GetMilestonesAsync(OWNER, REPOSITORY).ConfigureAwait(false);
result.Count().ShouldBeGreaterThan(0);

_milestone = result.OrderByDescending(m => m.Number).First();
_milestone = result.OrderByDescending(m => m.PublicNumber).First();
}

[Test]
Expand Down
3 changes: 2 additions & 1 deletion src/GitReleaseManager.Tests/ReleaseNotesBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ private static Milestone CreateMilestone(string version, string description = nu
{
Title = version,
Description = description,
Number = 1,
PublicNumber = 1,
InternalNumber = 123,
HtmlUrl = "https://github.com/gep13/FakeRepository/issues?q=milestone%3A" + version,
Version = new Version(version),
};
Expand Down

0 comments on commit daf2b7c

Please sign in to comment.