Skip to content

Commit 81930c6

Browse files
christian-schillingLMG
authored andcommitted
Remove pointless custom result enum
Change-Id: simplify-unapply
1 parent a2dd830 commit 81930c6

File tree

4 files changed

+9
-37
lines changed

4 files changed

+9
-37
lines changed

josh-proxy/src/lib.rs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub fn process_repo_update(repo_update: RepoUpdate) -> josh::JoshResult<String>
133133

134134
tracing::debug!("=== processed_old {:?}", old);
135135

136-
match josh::history::unapply_filter(
136+
josh::history::unapply_filter(
137137
&transaction,
138138
filterobj,
139139
original_target,
@@ -142,24 +142,7 @@ pub fn process_repo_update(repo_update: RepoUpdate) -> josh::JoshResult<String>
142142
josh_merge,
143143
reparent_orphans,
144144
&mut change_ids,
145-
)? {
146-
josh::UnapplyResult::Done(rewritten) => {
147-
tracing::debug!("rewritten");
148-
rewritten
149-
}
150-
josh::UnapplyResult::BranchDoesNotExist => {
151-
return Err(josh::josh_error("branch does not exist on remote"));
152-
}
153-
josh::UnapplyResult::RejectMerge(msg) => {
154-
return Err(josh::josh_error(&msg));
155-
}
156-
josh::UnapplyResult::RejectAmend(msg) => {
157-
return Err(josh::josh_error(&format!(
158-
"rejecting to amend {:?} with conflicting changes",
159-
msg
160-
)));
161-
}
162-
}
145+
)?
163146
};
164147

165148
let oid_to_push = if josh_merge {

src/bin/josh-filter.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,17 +340,14 @@ fn run_filter(args: Vec<String>) -> josh::JoshResult<i32> {
340340
false,
341341
None,
342342
&mut None,
343-
)? {
344-
josh::UnapplyResult::Done(rewritten) => {
343+
) {
344+
Ok(rewritten) => {
345345
repo.reference(&src, rewritten, true, "unapply_filter")?;
346346
}
347-
josh::UnapplyResult::RejectMerge(msg) => {
347+
Err(JoshError(msg)) => {
348348
println!("{}", msg);
349349
return Ok(1);
350350
}
351-
_ => {
352-
return Ok(1);
353-
}
354351
}
355352
}
356353

src/history.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ pub fn unapply_filter(
278278
keep_orphans: bool,
279279
reparent_orphans: Option<git2::Oid>,
280280
change_ids: &mut Option<Vec<Change>>,
281-
) -> JoshResult<UnapplyResult> {
281+
) -> JoshResult<git2::Oid> {
282282
let mut bm = std::collections::HashMap::new();
283283
let mut ret = original_target;
284284

@@ -307,7 +307,7 @@ pub fn unapply_filter(
307307
tracing::info!("Had to go through the whole thing",);
308308
find_original(transaction, filterobj, original_target, new)?
309309
};
310-
return Ok(UnapplyResult::Done(ret));
310+
return Ok(ret);
311311
}
312312

313313
tracing::info!("before walk");
@@ -461,7 +461,7 @@ pub fn unapply_filter(
461461
parent_count,
462462
module_commit.summary().unwrap_or_default()
463463
);
464-
return Ok(UnapplyResult::RejectMerge(msg));
464+
return Err(josh_error(&msg));
465465
}
466466
}
467467
};
@@ -481,7 +481,7 @@ pub fn unapply_filter(
481481
}
482482

483483
tracing::trace!("done {:?}", ret);
484-
Ok(UnapplyResult::Done(ret))
484+
Ok(ret)
485485
}
486486

487487
fn select_parent_commits<'a>(

src/lib.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ pub mod housekeeping;
4646
pub mod query;
4747
pub mod shell;
4848

49-
#[derive(Clone)]
50-
pub enum UnapplyResult {
51-
Done(git2::Oid),
52-
RejectMerge(String),
53-
RejectAmend(String),
54-
BranchDoesNotExist,
55-
}
56-
5749
pub struct Change {
5850
pub author: String,
5951
pub id: Option<String>,

0 commit comments

Comments
 (0)