style: code style

This commit is contained in:
2020-07-19 21:43:40 +08:00
parent be2b083c02
commit 7cdb6c25e5

View File

@@ -154,19 +154,19 @@ fn install_commit_msg(force: bool) {
}
let git_hooks_commit_msg = git_hooks.join("commit-msg");
if git_hooks_commit_msg.exists() && !force {
exit_with_error_message(&format!("File {:?} exists! or try forceinstall.", git_hooks_commit_msg));
exit_with_error_message(&format!("File {:?} exists! or try {}forceinstall{}.", git_hooks_commit_msg, BOLD, END));
}
print_info(&format!("Copy file: {:?} to: {:?}", commig_msg_exec_file, git_hooks_commit_msg));
let commig_msg_exec_file_content = fs::read(&commig_msg_exec_file).unwrap_or_else(|e| {
exit_with_error_message(&format!("Read file: {:?} failed: {}.", commig_msg_exec_file, e));
});
fs::write(&git_hooks_commit_msg, commig_msg_exec_file_content).unwrap_or_else(|e| {
exit_with_error_message(&format!("Write file: {:?} failed: {}.", git_hooks_commit_msg, e));
});
fs::set_permissions(&git_hooks_commit_msg, PermissionsExt::from_mode(0o755)).unwrap_or_else(|e| {
exit_with_error_message(&format!("Apply executable permission on file: {:?} failed: {}.", git_hooks_commit_msg, e));
});
let commig_msg_exec_file_content = fs::read(&commig_msg_exec_file).unwrap_or_else(|e|
exit_with_error_message(&format!("Read file: {:?}, failed: {}", commig_msg_exec_file, e))
);
fs::write(&git_hooks_commit_msg, commig_msg_exec_file_content).unwrap_or_else(|e|
exit_with_error_message(&format!("Write file: {:?}, failed: {}", git_hooks_commit_msg, e))
);
fs::set_permissions(&git_hooks_commit_msg, PermissionsExt::from_mode(0o755)).unwrap_or_else(|e|
exit_with_error_message(&format!("Apply executable permission on file: {:?}, failed: {}", git_hooks_commit_msg, e))
);
print_ok("Install commit-msg to repo successed!");
}