Skip to content

Commit a18bf51

Browse files
committed
Fixed a bug related to read write permissions
1 parent 79bf291 commit a18bf51

File tree

3 files changed

+71
-22
lines changed

3 files changed

+71
-22
lines changed

Cargo.lock

Lines changed: 39 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@ colored = "1.7"
1010
git2 = "0.8"
1111
fs_extra = "1.1.0"
1212
question = "0.2.2"
13+
rpassword = "3.0.2"
1314
ansi_term = "0.11"
1415

1516
[build-dependencies]
1617
winres = "0.1.9"
18+
19+
[profile.release]
20+
opt-level = 'z'
21+
codegen-units = 1
22+
std = {default-features=false}
23+
debug = false
24+
lto = true

src/main.rs

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,19 @@ fn download_deps()
8282
println!("Number of submodules: {}", submodules.len());
8383

8484
// Prevent shitty error case since the libgit2 sdk sucks. (This bug is present in the C version of the API as well)
85-
let mut file = match File::open(".git/config")
86-
{
87-
Ok(file) => file,
88-
Err(e) => panic!("Failed to open .git/config file: {}", e),
89-
};
9085
let mut contents = String::new();
91-
match file.read_to_string(&mut contents)
9286
{
93-
Ok(contents) => contents,
94-
Err(e) => panic!("Failed to read from .git/config file: {}", e),
95-
};
87+
let mut file = match File::open(".git/config")
88+
{
89+
Ok(file) => file,
90+
Err(e) => panic!("Failed to open .git/config file: {}", e),
91+
};
92+
match file.read_to_string(&mut contents)
93+
{
94+
Ok(contents) => contents,
95+
Err(e) => panic!("Failed to read from .git/config file: {}", e),
96+
};
97+
}
9698

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

113115
if !cfp.exists()
114116
{
115-
println!("Detected already inialized submodule {}", submodule.name().unwrap());
116-
println!("Making sure the deps/[submodule] dir is valid to prevent bug in libgit2.");
117-
118-
let mut file = match File::create(cfp)
117+
if Path::new(&format!("gitdir: ../../.git/modules/{}", submodule.path().display())).exists()
119118
{
120-
Ok(file) => { println!("Wrote .git file for {}", submodule.name().unwrap()); file },
121-
Err(e) => panic!("Failed to create .git file for submodule: {}", e),
122-
};
123-
124-
let newcontent = &format!("gitdir: ../../.git/modules/{}", submodule.path().display());
125-
file.write_all(newcontent.as_bytes()).unwrap();
119+
println!("Detected already inialized submodule {}", submodule.name().unwrap());
120+
println!("Making sure the deps/[submodule] dir is valid to prevent bug in libgit2.");
121+
122+
let mut file = match File::create(cfp)
123+
{
124+
Ok(file) => { println!("Wrote .git file for {}", submodule.name().unwrap()); file },
125+
Err(e) => panic!("Failed to create .git file for submodule: {}", e),
126+
};
127+
128+
let newcontent = &format!("gitdir: ../../.git/modules/{}", submodule.path().display());
129+
file.write_all(newcontent.as_bytes()).unwrap();
130+
}
126131
}
127132
}
128133

0 commit comments

Comments
 (0)