Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions src/admin/transfer_crates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
models::{Crate, OwnerKind, User},
schema::{crate_owners, crates, users},
};
use std::process::exit;

use crate::tasks::spawn_blocking;
use diesel::prelude::*;
Expand All @@ -24,7 +23,7 @@
pub async fn run(opts: Opts) -> anyhow::Result<()> {
spawn_blocking(move || {
let conn = &mut db::oneoff_connection()?;
conn.transaction(|conn| transfer(opts, conn))?;
transfer(opts, conn)?;

Check warning on line 26 in src/admin/transfer_crates.rs

View check run for this annotation

Codecov / codecov/patch

src/admin/transfer_crates.rs#L26

Added line #L26 was not covered by tests
Ok(())
})
.await
Expand All @@ -48,14 +47,18 @@
println!("from: {:?}", from.gh_id);
println!("to: {:?}", to.gh_id);

get_confirm("continue?");
if !dialoguer::confirm("continue?") {
return Ok(());
}

Check warning on line 52 in src/admin/transfer_crates.rs

View check run for this annotation

Codecov / codecov/patch

src/admin/transfer_crates.rs#L50-L52

Added lines #L50 - L52 were not covered by tests
}

let prompt = format!(
"Are you sure you want to transfer crates from {} to {}?",
from.gh_login, to.gh_login
);
get_confirm(&prompt);
if !dialoguer::confirm(&prompt) {
return Ok(());
}

Check warning on line 61 in src/admin/transfer_crates.rs

View check run for this annotation

Codecov / codecov/patch

src/admin/transfer_crates.rs#L59-L61

Added lines #L59 - L61 were not covered by tests

let crate_owners = crate_owners::table
.filter(crate_owners::owner_id.eq(from.id))
Expand All @@ -71,17 +74,13 @@
}
}

if !dialoguer::confirm("commit?") {
return Ok(());
}

Check warning on line 80 in src/admin/transfer_crates.rs

View check run for this annotation

Codecov / codecov/patch

src/admin/transfer_crates.rs#L77-L80

Added lines #L77 - L80 were not covered by tests
diesel::update(crate_owners)
.set(crate_owners::owner_id.eq(to.id))
.execute(conn)?;

get_confirm("commit?");

Ok(())
}

fn get_confirm(msg: &str) {
if !dialoguer::confirm(msg) {
exit(0);
}
}