Skip to content

Commit f181a1e

Browse files
authored
Version check fix + Rustfmt (mimblewimble#293) (mimblewimble#294)
* Correct node version check * rustfmt * update pre-commit hook
1 parent a97dc61 commit f181a1e

File tree

2 files changed

+18
-33
lines changed

2 files changed

+18
-33
lines changed

.hooks/pre-commit

+12-21
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,29 @@ if [ $? != 0 ]; then
2222
exit 1
2323
fi
2424

25-
result=0
2625
problem_files=()
2726

28-
printf "[pre_commit] rustfmt "
29-
27+
# first collect all the files that need reformatting
3028
for file in $(git diff --name-only --cached); do
3129
if [ ${file: -3} == ".rs" ]; then
32-
# first collect all the files that need reformatting
3330
rustfmt --check $file &>/dev/null
3431
if [ $? != 0 ]; then
3532
problem_files+=($file)
36-
result=1
3733
fi
3834
fi
3935
done
4036

41-
# now reformat all the files that need reformatting
42-
for file in ${problem_files[@]}; do
43-
rustfmt $file
44-
done
45-
46-
# and let the user know what just happened (and which files were affected)
47-
printf "\033[0;32mok\033[0m \n"
48-
if [ $result != 0 ]; then
49-
# printf "\033[0;31mrustfmt\033[0m \n"
50-
printf "[pre_commit] the following files were rustfmt'd (not yet committed): \n"
51-
52-
for file in ${problem_files[@]}; do
53-
printf "\033[0;31m $file\033[0m \n"
54-
done
37+
if [ ${#problem_files[@]} == 0 ]; then
38+
# nothing to do
39+
printf "[pre_commit] rustfmt \033[0;32mok\033[0m \n"
40+
else
41+
# reformat the files that need it and re-stage them.
42+
printf "[pre_commit] the following files were rustfmt'd before commit: \n"
43+
for file in ${problem_files[@]}; do
44+
rustfmt $file
45+
git add $file
46+
printf "\033[0;32m $file\033[0m \n"
47+
done
5548
fi
5649

5750
exit 0
58-
# to actually fail the build on rustfmt failure -
59-
# exit $result

src/cmd/wallet.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use semver::Version;
2020
use std::thread;
2121
use std::time::Duration;
2222

23-
const MIN_COMPAT_NODE_VERSION: &str = "2.0.0-beta.1";
23+
const MIN_COMPAT_NODE_VERSION: &str = "3.0.0";
2424

2525
pub fn wallet_command<C>(
2626
wallet_args: &ArgMatches<'_>,
@@ -36,24 +36,18 @@ where
3636
let tor_config = config.members.unwrap().tor;
3737

3838
// Check the node version info, and exit with report if we're not compatible
39-
//let mut node_client = HTTPNodeClient::new(&wallet_config.check_node_api_http_addr, None);
4039
let global_wallet_args = wallet_args::parse_global_args(&wallet_config, &wallet_args)
4140
.expect("Can't read configuration file");
4241
node_client.set_node_api_secret(global_wallet_args.node_api_secret.clone());
4342

4443
// This will also cache the node version info for calls to foreign API check middleware
4544
if let Some(v) = node_client.clone().get_version_info() {
46-
// Isn't going to happen just yet (as of 2.0.0) but keep this here for
47-
// the future. the nodeclient's get_version_info will return 1.0 if
48-
// it gets a 404 for the version function
4945
if Version::parse(&v.node_version) < Version::parse(MIN_COMPAT_NODE_VERSION) {
50-
let version = if v.node_version == "1.0.0" {
51-
"1.x.x series"
52-
} else {
53-
&v.node_version
54-
};
55-
println!("The Grin Node in use (version {}) is outdated and incompatible with this wallet version.", version);
56-
println!("Please update the node to version 2.0.0 or later and try again.");
46+
println!("The Grin Node in use (version {}) is outdated and incompatible with this wallet version.", v.node_version);
47+
println!(
48+
"Please update the node to version {} or later and try again.",
49+
MIN_COMPAT_NODE_VERSION
50+
);
5751
return 1;
5852
}
5953
}

0 commit comments

Comments
 (0)