/// /// Convenience method to obtain the SHA256 hash of a given script /// std::string calculate_script_hash(const repository &repo, const script_action &action, const std::string &script_path) { switch (action) { case script_action::install: { string path = repo.install_script_path() + "/" + script_path; ifstream ifs{path.c_str()}; return read_install_statements(ifs).sha256_sum(); } case script_action::upgrade: { string path = repo.upgrade_script_path() + "/" + script_path; ifstream ifs{path.c_str()}; return read_upgrade_statements(ifs).sha256_sum(); } case script_action::rollback: { string path = repo.upgrade_script_path() + "/" + script_path; ifstream ifs{path.c_str()}; return read_rollback_statements(ifs).sha256_sum(); } } throw std::out_of_range{to_string(action)}; }