mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
comm: make sure that our version check is reliable
Rework the logic of the version check used in the database migration, and make sure that it is full functional to avoid confusion at release time. Changelog-Fixed: database: Correctly identity official release versions for database upgrade. Reported-by: @urza Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
8d825ef0b7
commit
8f94e8b943
@@ -3,6 +3,7 @@
|
||||
#include <common/version.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Only common/version.c can safely include this. */
|
||||
# include "version_gen.h"
|
||||
@@ -20,3 +21,15 @@ char *version_and_exit(const void *unused UNUSED)
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static bool cmp_release_version(const char *version) {
|
||||
if (version[0] != 'v')
|
||||
return false;
|
||||
return strspn(version+1, ".0123456789") == strlen(version+1);
|
||||
}
|
||||
|
||||
/* Released versions are of form v[year].[month]?(.patch)* */
|
||||
bool is_released_version(void)
|
||||
{
|
||||
return cmp_release_version(version());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user