Skip to content

Commit

Permalink
Merge pull request #239 from wakatime/misc/disable-updates
Browse files Browse the repository at this point in the history
Prevent upgrading wakatime-cli when built from source
  • Loading branch information
alanhamlett authored Mar 25, 2024
2 parents bcd4bd0 + 16e1707 commit d976d1c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions WakaTime/Extensions/StringExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ extension String {
}
return false
}

func trim() -> String {
self.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
}
}
6 changes: 6 additions & 0 deletions WakaTime/Helpers/Dependencies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ class Dependencies {
}
let outputData = outputPipe.fileHandleForReading.readDataToEndOfFile()
let output = String(decoding: outputData, as: UTF8.self)

// disable updating wakatime-cli when it was built from source
if output.trim() == "<local-build>" {
return true
}

let version: String?
if let regex = try? NSRegularExpression(pattern: "([0-9]+\\.[0-9]+\\.[0-9]+)"),
let match = regex.firstMatch(in: output, range: NSRange(output.startIndex..., in: output)),
Expand Down

0 comments on commit d976d1c

Please sign in to comment.