Allow portable drafts to publish to the connected server

This commit is contained in:
2026-10-10 02:18:48 +01:00
parent c74f7f3b41
commit 4cae37f950
12 changed files with 242 additions and 20 deletions
+11 -5
View File
@@ -465,9 +465,9 @@ func (a App) Run(ctx context.Context, args []string) error {
if metaErr != nil && !os.IsNotExist(metaErr) {
return metaErr
}
if d.Server != "" && d.Server != o.url {
return fmt.Errorf("draft belongs to server %s; select it with --url", d.Server)
}
origin := d
crossServer := d.Server != "" && d.Server != o.url
d = d.ForServer(o.url)
name := o.name
if name == "" {
name = d.Name
@@ -482,8 +482,14 @@ func (a App) Run(ctx context.Context, args []string) error {
if o.force {
expected = 0
}
request = protocol.Message{Type: protocol.Submit, Name: name, Source: source, CreateOnly: d.CreateOnly || o.createOnly, ExpectedVersion: expected}
if err := a.confirmAction("Publish "+name+" as an immutable version? Included schedules activate on acceptance.", o.yes); err != nil {
createOnly := d.CreateOnly || o.createOnly
// An explicit destination version (or force) permits intentional
// updates from an edit draft; never inherit the origin version.
if crossServer && (o.expected > 0 || o.force) {
createOnly = origin.CreateOnly || o.createOnly
}
request = protocol.Message{Type: protocol.Submit, Name: name, Source: source, CreateOnly: createOnly, ExpectedVersion: expected}
if err := a.confirmAction("Publish "+name+" to "+o.url+" as an immutable version? Included schedules activate on acceptance.", o.yes); err != nil {
return err
}
}