Skip to content

Commit

Permalink
Fixed a bug related to read write permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
VZout committed Apr 19, 2019
1 parent 79bf291 commit a18bf51
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 22 deletions.
42 changes: 39 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ colored = "1.7"
git2 = "0.8"
fs_extra = "1.1.0"
question = "0.2.2"
rpassword = "3.0.2"
ansi_term = "0.11"

[build-dependencies]
winres = "0.1.9"

[profile.release]
opt-level = 'z'
codegen-units = 1
std = {default-features=false}
debug = false
lto = true
43 changes: 24 additions & 19 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,19 @@ fn download_deps()
println!("Number of submodules: {}", submodules.len());

// Prevent shitty error case since the libgit2 sdk sucks. (This bug is present in the C version of the API as well)
let mut file = match File::open(".git/config")
{
Ok(file) => file,
Err(e) => panic!("Failed to open .git/config file: {}", e),
};
let mut contents = String::new();
match file.read_to_string(&mut contents)
{
Ok(contents) => contents,
Err(e) => panic!("Failed to read from .git/config file: {}", e),
};
let mut file = match File::open(".git/config")
{
Ok(file) => file,
Err(e) => panic!("Failed to open .git/config file: {}", e),
};
match file.read_to_string(&mut contents)
{
Ok(contents) => contents,
Err(e) => panic!("Failed to read from .git/config file: {}", e),
};
}

// Init and Update Submodules.
for mut submodule in submodules {
Expand All @@ -112,17 +114,20 @@ fn download_deps()

if !cfp.exists()
{
println!("Detected already inialized submodule {}", submodule.name().unwrap());
println!("Making sure the deps/[submodule] dir is valid to prevent bug in libgit2.");

let mut file = match File::create(cfp)
if Path::new(&format!("gitdir: ../../.git/modules/{}", submodule.path().display())).exists()
{
Ok(file) => { println!("Wrote .git file for {}", submodule.name().unwrap()); file },
Err(e) => panic!("Failed to create .git file for submodule: {}", e),
};

let newcontent = &format!("gitdir: ../../.git/modules/{}", submodule.path().display());
file.write_all(newcontent.as_bytes()).unwrap();
println!("Detected already inialized submodule {}", submodule.name().unwrap());
println!("Making sure the deps/[submodule] dir is valid to prevent bug in libgit2.");

let mut file = match File::create(cfp)
{
Ok(file) => { println!("Wrote .git file for {}", submodule.name().unwrap()); file },
Err(e) => panic!("Failed to create .git file for submodule: {}", e),
};

let newcontent = &format!("gitdir: ../../.git/modules/{}", submodule.path().display());
file.write_all(newcontent.as_bytes()).unwrap();
}
}
}

Expand Down

0 comments on commit a18bf51

Please sign in to comment.