Skip to content
Permalink
Browse files

Remove migration subcommand

  • Loading branch information...
vbrandl committed Jul 7, 2019
1 parent b8e4547 commit f3902f800f7e0c25564b42f4ecd1ff8a1d0e6182
Showing with 2 additions and 43 deletions.
  1. +0 −8 src/config.rs
  2. +2 −35 src/main.rs
@@ -46,14 +46,6 @@ pub(crate) struct Opt {
)]
/// The logfile
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<()> {
@@ -18,7 +18,6 @@ mod statics;

use crate::{
cache::CacheState,
config::Migration,
error::{Error, Result},
service::{Bitbucket, FormService, GitHub, Gitlab, Service},
statics::{CLIENT, CSS, FAVICON, OPT, REPO_COUNT, VERSION_INFO},
@@ -35,7 +34,7 @@ use git2::Repository;
use number_prefix::{NumberPrefix, Prefixed, Standalone};
use std::{
borrow::Cow,
fs::{create_dir_all, read_dir, rename},
fs::create_dir_all,
path::Path,
process::Command,
sync::atomic::Ordering,
@@ -372,39 +371,7 @@ fn start_server() -> Result<()> {
.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<()> {
config::init()?;
match &OPT.migrate {
None => start_server(),
Some(migration) => match migration {
Migration::CacheCommitCount => migrate_cache(),
},
}
start_server()
}

0 comments on commit f3902f8

Please sign in to comment.
You can’t perform that action at this time.