-
Notifications
You must be signed in to change notification settings - Fork 43
feat(changelog): changelog note command for PR-less entries #3923
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fa11cad
c1f597a
a76ea18
1b42111
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,9 @@ public record CreateChangelogArguments | |
| /// unauthorized GITHUB_TOKEN would otherwise silently produce unfiltered, title-less changelogs. | ||
| /// </summary> | ||
| public bool StrictFetch { get; init; } | ||
|
|
||
| public bool IsNote { get; init; } | ||
| public string? NoteName { get; init; } | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -146,6 +149,72 @@ public async Task<bool> CreateChangelog(IDiagnosticsCollector collector, CreateC | |
| } | ||
| } | ||
|
|
||
| public async Task<bool> CreateNote(IDiagnosticsCollector collector, CreateChangelogArguments input, Cancel ctx) | ||
| { | ||
| try | ||
| { | ||
| var cliDescription = input.Description; | ||
| input = EnrichFromCI(input); | ||
|
Mpdreamz marked this conversation as resolved.
|
||
|
|
||
| var config = await _configLoader.LoadChangelogConfiguration(collector, input.Config, ctx); | ||
| if (config == null) | ||
| { | ||
| collector.EmitError(string.Empty, "Failed to load changelog configuration"); | ||
| return false; | ||
| } | ||
|
|
||
| input = ApplyConfigDefaults(input, config); | ||
|
Mpdreamz marked this conversation as resolved.
|
||
|
|
||
| // Mirror CreateChangelog: discard CI-injected description when extraction is disabled | ||
| if (input.ExtractionDisabled | ||
| && string.IsNullOrWhiteSpace(cliDescription) | ||
| && !string.IsNullOrWhiteSpace(input.Description)) | ||
| { | ||
| _logger.LogInformation("Clearing CI-provided description because release note extraction is disabled"); | ||
| input = input with { Description = null }; | ||
| } | ||
|
|
||
| // Validate PR citation format (same rule as `add`: numeric refs require --owner/--repo) | ||
| if (input.Prs is { Length: > 1 }) | ||
| { | ||
| if (!_validator.ValidateMultiplePrFormat(collector, input.Prs, input.Owner, input.Repo)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Given the intended rule here (numeric refs require repo context), this should validate each PR entry (or fail when any entry is numeric and repo context is missing), not only the all-numeric case.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 1b42111 — changed |
||
| return false; | ||
| } | ||
| else if (!_validator.ValidatePrFormat(collector, input.Prs?.FirstOrDefault(), input.Owner, input.Repo)) | ||
| return false; | ||
|
|
||
| // Validate issue citation format | ||
| if (input.Issues is { Length: > 1 }) | ||
| { | ||
| if (!_validator.ValidateMultipleIssueFormat(collector, input.Issues, input.Owner, input.Repo)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same gap for issues: in the multi-value branch, Please apply per-entry validation (or reject when any numeric value is present without owner/repo context), matching the single-value validation rule.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 1b42111 — same |
||
| return false; | ||
| } | ||
| else if (!_validator.ValidateIssueFormat(collector, input.Issues?.FirstOrDefault(), input.Owner, input.Repo)) | ||
| return false; | ||
|
|
||
| if (!_validator.ValidateRequiredFields(collector, input, prFetchFailed: false)) | ||
|
Mpdreamz marked this conversation as resolved.
|
||
| return false; | ||
|
|
||
| if (!_validator.ValidateNoteProducts(collector, input)) | ||
| return false; | ||
|
|
||
| if (!_validator.ValidateAgainstConfiguration(collector, input, config)) | ||
| return false; | ||
|
|
||
| return await _fileWriter.WriteNoteAsync(input, config, ctx); | ||
| } | ||
| catch (IOException ioEx) | ||
| { | ||
| collector.EmitError(string.Empty, $"IO error creating note: {ioEx.Message}", ioEx); | ||
| return false; | ||
| } | ||
| catch (UnauthorizedAccessException uaEx) | ||
| { | ||
| collector.EmitError(string.Empty, $"Access denied creating note: {uaEx.Message}", uaEx); | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| internal static CreateChangelogArguments ApplyConfigDefaults(CreateChangelogArguments input, ChangelogConfiguration config) => | ||
| // Filename strategy is always Pr now; UsePrNumber is kept for backward compat but is effectively always true. | ||
| input with | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.