Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue 292 New version alert was not displayed due to a semver regex issue. #300

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Released on
- [Issue 290](https://github.com/veeso/termscp/issues/290): Password prompt was broken
- [Issue 298](https://github.com/veeso/termscp/issues/298): tuirealm 2.x
- Fixed some performance issues where sometimes the app froze for a couple of seconds, thanks to this <https://github.com/veeso/tui-realm/pull/78>.
- [Issue 292](https://github.com/veeso/termscp/issues/292): New version alert was not displayed due to a semver regex issue.
- Logging: filter out messages not related to termscp or remotefs

## 0.15.0

Expand Down
1 change: 1 addition & 0 deletions src/system/auto_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ impl Update {

/// In case received version is newer than current one, version as Some is returned; otherwise None
fn check_version(r: Release) -> Option<Release> {
debug!("got version from GitHub: {}", r.version);
match parse_semver(r.version.as_str()) {
Some(new_version) => {
// Check if version is different
Expand Down
6 changes: 5 additions & 1 deletion src/system/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ pub fn init(level: LogLevel) -> Result<(), String> {
let file = open_file(log_file_path.as_path(), true, true, false)
.map_err(|e| format!("Failed to open file {}: {}", log_file_path.display(), e))?;
// Prepare log config
let config = ConfigBuilder::new().set_time_format_rfc3339().build();
let config = ConfigBuilder::new()
.set_time_format_rfc3339()
.add_filter_allow_str("termscp")
.add_filter_allow_str("remotefs")
.build();
// Make logger
WriteLogger::init(level, config, file).map_err(|e| format!("Failed to initialize logger: {e}"))
}
Expand Down
4 changes: 3 additions & 1 deletion src/utils/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static REMOTE_SMB_OPT_REGEX: Lazy<Regex> =
* - group 1: Version
* E.g. termscp-0.3.2 => 0.3.2; v0.4.0 => 0.4.0
*/
static SEMVER_REGEX: Lazy<Regex> = lazy_regex!(r".*(:?[0-9]\.[0-9]\.[0-9])");
static SEMVER_REGEX: Lazy<Regex> = lazy_regex!(r"v?((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*))");

/**
* Regex matches:
Expand Down Expand Up @@ -835,6 +835,8 @@ mod tests {
assert_eq!(parse_semver("v0.4.1").unwrap(), String::from("0.4.1"),);
assert_eq!(parse_semver("1.0.0").unwrap(), String::from("1.0.0"),);
assert!(parse_semver("v1.1").is_none());

assert_eq!(parse_semver("10.15.10"), Some("10.15.10".to_string()));
}

#[test]
Expand Down
Loading