Add helper function to create version string

And remove all the duplicate code.

Depending on the situation prof_get_version() will return:
* 0.13.1
* 0.13.1dev
* 0.13.1dev.master.69d8c1f9
This commit is contained in:
Michael Vetter
2023-07-25 20:58:15 +02:00
parent 13af6c96dc
commit 22b1d14b67
9 changed files with 35 additions and 89 deletions

View File

@@ -62,6 +62,10 @@
#include "log.h"
#include "common.h"
#ifdef HAVE_GIT_VERSION
#include "gitversion.h"
#endif
struct curl_data_t
{
char* buffer;
@@ -688,3 +692,20 @@ glib_hash_table_free(GHashTable* hash_table)
g_hash_table_remove_all(hash_table);
g_hash_table_unref(hash_table);
}
/* build profanity version string.
* example: 0.13.1dev.master.69d8c1f9
*/
gchar*
prof_get_version(void)
{
if (strcmp(PACKAGE_STATUS, "development") == 0) {
#ifdef HAVE_GIT_VERSION
return g_strdup_printf("%sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
#else
return g_strdup_printf("%sdev", PACKAGE_VERSION);
#endif
} else {
return g_strdup_printf("%s", PACKAGE_VERSION);
}
}