Make find_release_notes() more testable.
authorCarl Hetherington <cth@carlh.net>
Sun, 28 Aug 2022 23:12:46 +0000 (01:12 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 28 Aug 2022 23:12:46 +0000 (01:12 +0200)
src/lib/release_notes.cc
src/lib/release_notes.h

index b1eb95257bf5c479e42032432b4261502a387476..face4df2c6b9e6b4adbfb73df09881254a5b9fb3 100644 (file)
@@ -31,19 +31,21 @@ using boost::optional;
 
 
 optional<string>
-find_release_notes()
+find_release_notes(optional<string> current)
 {
        auto last = Config::instance()->last_release_notes_version();
-       auto current = string(dcpomatic_version);
-       if (last && *last == current) {
+       if (!current) {
+               current = string(dcpomatic_version);
+       }
+       if (last && *last == *current) {
                return {};
        }
 
-       Config::instance()->set_last_release_notes_version(current);
+       Config::instance()->set_last_release_notes_version(*current);
 
-       const string header = String::compose("<h1>DCP-o-matic %1 release notes</h1>", current);
+       const string header = String::compose("<h1>DCP-o-matic %1 release notes</h1>", *current);
 
-       if (current == "2.16.18") {
+       if (*current == "2.16.18") {
                return header +
                        _("In this version there are changes to the way that subtitles are positioned.  "
                          "Positioning should now be more correct, with respect to the standards, but you "
index 36f66d25775b6fd85bbb8c489f65cb3ead82ca30..a5026b432103c7a0045fe4c481b6bdfec4f469bf 100644 (file)
@@ -23,4 +23,4 @@
 #include <string>
 
 
-extern boost::optional<std::string> find_release_notes();
+extern boost::optional<std::string> find_release_notes(boost::optional<std::string> current = boost::optional<std::string>());