Skip to content

Commit

Permalink
Fix for getting the commits
Browse files Browse the repository at this point in the history
  • Loading branch information
omegaleo committed Apr 26, 2023
1 parent ad923e2 commit 9308fb3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions changelog-generator/UnityFlow.ChangelogGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ static async Task Main(string[] args) {
// Get the previous release to compare with
var previousRelease = await client.Repository.Release.GetAll(owner, repo);
// var previousReleaseTag = previousRelease.FirstOrDefault()?.TagName;
var previousReleaseDate = previousRelease.FirstOrDefault()?.CreatedAt.UtcDateTime ?? DateTime.Parse("2000-01-01 00:00:00");
var previousReleaseDate = previousRelease.FirstOrDefault(x => x.Id != release.Id)?.CreatedAt.UtcDateTime ?? DateTime.Parse("2000-01-01 00:00:00");

// Filter the commits to only include those since the last release
var filteredCommits = commits.Where(commit => commit.Commit.Author.Date >= previousReleaseDate)
.ToList();

// Generate the changelog
var changelog = $"## $ChangeLog{Environment.NewLine}";
var changelog = $"## ChangeLog{Environment.NewLine}";
foreach (var commit in filteredCommits) {
var commitMessage = commit.Commit.Message.Trim();
if (Regex.IsMatch(commitMessage, "^(Fix|Implemented|Added|Removed|Changed|Modified)"))
Expand All @@ -52,7 +52,7 @@ static async Task Main(string[] args) {
var updatedRelease = await client.Repository.Release.Edit(owner, repo, release.Id, update);


changelog = changelog.Replace("$ChangeLog", releaseTag);
changelog = changelog.Replace("## ChangeLog", "## " + releaseTag);

var currentChangelog = File.ReadAllText(changelogFilePath);

Expand Down

0 comments on commit 9308fb3

Please sign in to comment.