mirror of
https://github.com/kovetskiy/mark.git
synced 2026-03-14 14:17:37 +08:00
fix: handle nil meta in dry-run mode when PageID is set
page.ResolvePage requires non-nil metadata and would error immediately when called with meta == nil (e.g. when --page-id is used and the file has no metadata header, or when metadata is intentionally suppressed). Guard the call: when meta != nil use ResolvePage as before; when meta is nil but PageID is provided, validate the page exists via api.GetPageByID instead; when neither is set the earlier mandatory- field check already returns an error, so no further action is needed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
4e3b90c03c
commit
66120b937e
6
mark.go
6
mark.go
@ -234,9 +234,15 @@ func ProcessFile(file string, api *confluence.API, config Config) (*confluence.P
|
|||||||
markdown = page.SubstituteLinks(markdown, links)
|
markdown = page.SubstituteLinks(markdown, links)
|
||||||
|
|
||||||
if config.DryRun {
|
if config.DryRun {
|
||||||
|
if meta != nil {
|
||||||
if _, _, err := page.ResolvePage(true, api, meta); err != nil {
|
if _, _, err := page.ResolvePage(true, api, meta); err != nil {
|
||||||
return nil, fmt.Errorf("unable to resolve page location: %w", err)
|
return nil, fmt.Errorf("unable to resolve page location: %w", err)
|
||||||
}
|
}
|
||||||
|
} else if config.PageID != "" {
|
||||||
|
if _, err := api.GetPageByID(config.PageID); err != nil {
|
||||||
|
return nil, fmt.Errorf("unable to resolve page by ID: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.CompileOnly || config.DryRun {
|
if config.CompileOnly || config.DryRun {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user