Skip to content

Commit

Permalink
Fix git update
Browse files Browse the repository at this point in the history
  • Loading branch information
maralla committed Mar 30, 2018
1 parent 34edbb7 commit 93b1e52
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ fn fetch(repo: &Repository, name: &str) -> Result<()> {
Ok(())
}

fn clone_real<P: AsRef<Path>>(name: &str, target: P) -> Result<()> {
let repo = git2::Repository::init(&target)?;
fn sync_repo(repo: &Repository, name: &str) -> Result<()> {
fetch(&repo, name)?;
let reference = "HEAD";
let oid = repo.refname_to_id(reference)?;
Expand All @@ -30,7 +29,8 @@ fn clone_real<P: AsRef<Path>>(name: &str, target: P) -> Result<()> {
}

pub fn clone<P: AsRef<Path>>(name: &str, target: P) -> Result<()> {
let result = clone_real(name, &target);
let repo = git2::Repository::init(&target)?;
let result = sync_repo(&repo, name);
if result.is_err() {
fs::remove_dir_all(&target)?;
}
Expand All @@ -39,18 +39,18 @@ pub fn clone<P: AsRef<Path>>(name: &str, target: P) -> Result<()> {

pub fn update<P: AsRef<Path>>(name: &str, path: P) -> Result<()> {
let repo = Repository::open(&path)?;
fetch(&repo, name)
sync_repo(&repo, name)
}

fn update_submodules(repo: &Repository) -> Result<()> {

fn add_subrepos(repo: &Repository, list: &mut Vec<Repository>)
-> Result<()> {
for mut subm in repo.submodules()? {
subm.update(true, None)?;
list.push(subm.open()?);
}
Ok(())
fn add_subrepos(repo: &Repository, list: &mut Vec<Repository>) -> Result<()> {
for mut subm in repo.submodules()? {
subm.update(true, None)?;
list.push(subm.open()?);
}
Ok(())
}

let mut repos = Vec::new();
add_subrepos(repo, &mut repos)?;
Expand Down

0 comments on commit 93b1e52

Please sign in to comment.