use std::path::{Path, PathBuf};
use std::fs::TempDir;
use std::io;
use url::Url;
use Repository;
pub fn repo_init() -> (TempDir, Repository) {
let td = TempDir::new("test").unwrap();
let repo = Repository::init(td.path()).unwrap();
{
let mut config = repo.config().unwrap();
config.set_str("user.name", "name").unwrap();
config.set_str("user.email", "email").unwrap();
let mut index = repo.index().unwrap();
let id = index.write_tree().unwrap();
let tree = repo.find_tree(id).unwrap();
let sig = repo.signature().unwrap();
repo.commit(Some("HEAD"), &sig, &sig, "initial",
&tree, &[]).unwrap();
}
(td, repo)
}
pub fn path2url(path: &Path) -> String {
let path = ::std::old_path::Path::new(path.to_str().unwrap());
Url::from_file_path(&path).unwrap().to_string()
}
pub fn realpath(original: &Path) -> io::Result<PathBuf> {
Ok(original.to_path_buf())
}