cob: Don't lose state when lifecycling

It was previously possible to switch a merged patch to "open", losing
the merge state.
This commit is contained in:
cloudhead 2023-11-29 11:40:40 +01:00
parent 5b1cdbaa4a
commit 538ca1e44d
No known key found for this signature in database
1 changed files with 18 additions and 10 deletions

View File

@ -706,17 +706,25 @@ impl Patch {
self.title = title; self.title = title;
self.target = target; self.target = target;
} }
Action::Lifecycle { state } => match state { Action::Lifecycle { state } => {
Lifecycle::Open => { let valid = self.state == State::Draft
self.state = State::Open { conflicts: vec![] }; || self.state == State::Archived
|| self.state == State::Open { conflicts: vec![] };
if valid {
match state {
Lifecycle::Open => {
self.state = State::Open { conflicts: vec![] };
}
Lifecycle::Draft => {
self.state = State::Draft;
}
Lifecycle::Archived => {
self.state = State::Archived;
}
}
} }
Lifecycle::Draft => { }
self.state = State::Draft;
}
Lifecycle::Archived => {
self.state = State::Archived;
}
},
Action::Label { labels } => { Action::Label { labels } => {
self.labels = BTreeSet::from_iter(labels); self.labels = BTreeSet::from_iter(labels);
} }