Skip to content

Commit

Permalink
fix: issue 292 New version alert was not displayed due to a semver re…
Browse files Browse the repository at this point in the history
…gex issue.
  • Loading branch information
veeso committed Oct 14, 2024
1 parent 7eb913e commit bb04b66
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
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

0 comments on commit bb04b66

Please sign in to comment.