Remove migration subcommand
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Valentin Brandl 2019-07-07 18:27:50 +02:00
parent b8e454762e
commit f3902f800f
No known key found for this signature in database
GPG Key ID: 30D341DD34118D7D
2 changed files with 2 additions and 43 deletions

View File

@ -46,14 +46,6 @@ pub(crate) struct Opt {
)] )]
/// The logfile /// The logfile
pub(crate) logfile: PathBuf, pub(crate) logfile: PathBuf,
#[structopt(subcommand)]
pub(crate) migrate: Option<Migration>,
}
#[derive(StructOpt, Debug, Clone, Copy)]
pub(crate) enum Migration {
#[structopt(name = "migrate-commit-count")]
CacheCommitCount,
} }
pub(crate) fn init() -> Result<()> { pub(crate) fn init() -> Result<()> {

View File

@ -18,7 +18,6 @@ mod statics;
use crate::{ use crate::{
cache::CacheState, cache::CacheState,
config::Migration,
error::{Error, Result}, error::{Error, Result},
service::{Bitbucket, FormService, GitHub, Gitlab, Service}, service::{Bitbucket, FormService, GitHub, Gitlab, Service},
statics::{CLIENT, CSS, FAVICON, OPT, REPO_COUNT, VERSION_INFO}, statics::{CLIENT, CSS, FAVICON, OPT, REPO_COUNT, VERSION_INFO},
@ -35,7 +34,7 @@ use git2::Repository;
use number_prefix::{NumberPrefix, Prefixed, Standalone}; use number_prefix::{NumberPrefix, Prefixed, Standalone};
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{create_dir_all, read_dir, rename}, fs::create_dir_all,
path::Path, path::Path,
process::Command, process::Command,
sync::atomic::Ordering, sync::atomic::Ordering,
@ -372,39 +371,7 @@ fn start_server() -> Result<()> {
.run()?) .run()?)
} }
fn migrate_cache() -> Result<()> {
let mut backup_cache = OPT.cachedir.clone();
backup_cache.set_extension("bak");
rename(&OPT.cachedir, backup_cache)?;
let outdir = OPT.outdir.display().to_string();
let cachedir = OPT.cachedir.display().to_string();
for service in read_dir(&OPT.outdir)? {
let service = service?;
for namespace in read_dir(service.path())? {
let namespace = namespace?;
for repo in read_dir(namespace.path())? {
let repo_path = repo?.path().display().to_string();
let repo_path: String =
repo_path
.split(&outdir)
.fold(String::new(), |mut acc, next| {
acc.push_str(next);
acc
});
println!("{}", repo_path);
hoc(&repo_path, &outdir, &cachedir)?;
}
}
}
Ok(())
}
fn main() -> Result<()> { fn main() -> Result<()> {
config::init()?; config::init()?;
match &OPT.migrate { start_server()
None => start_server(),
Some(migration) => match migration {
Migration::CacheCommitCount => migrate_cache(),
},
}
} }