From 47479eb0e7d2f559836f02e9096308844ec2632f Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 21 Nov 2019 18:48:20 +0100 Subject: [PATCH] MINOR: version: emit the link to the known bugs in output of "haproxy -v" The link to the known bugs page for the current version is built and reported there. When it is a development version (less than 2 dots), instead a link to github open issues is reported as there's no way to be sure about the current situation in this case and it's better that users report their trouble there. --- include/common/version.h | 6 ++++++ src/haproxy.c | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/common/version.h b/include/common/version.h index fd5c954401..b610c50e07 100644 --- a/include/common/version.h +++ b/include/common/version.h @@ -42,6 +42,12 @@ #define PRODUCT_STATUS "Status: development branch - not safe for use in production." #endif +#ifdef CONFIG_PRODUCT_URL_BUGS +#define PRODUCT_URL_BUGS CONFIG_PRODUCT_URL_BUGS +#else +#define PRODUCT_URL_BUGS "http://www.haproxy.org/bugs/bugs-%s.html" +#endif + #ifdef CONFIG_PRODUCT_URL #define PRODUCT_URL CONFIG_PRODUCT_URL #else diff --git a/src/haproxy.c b/src/haproxy.c index 32d9d33cec..b03d0ad5e4 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -545,6 +545,26 @@ static void display_version() { printf("HA-Proxy version %s %s - https://haproxy.org/\n" PRODUCT_STATUS "\n", haproxy_version, haproxy_date); + + if (strlen(PRODUCT_URL_BUGS) > 0) { + char base_version[20]; + int dots = 0; + char *del; + + /* only retrieve the base version without distro-specific extensions */ + for (del = haproxy_version; *del; del++) { + if (*del == '.') + dots++; + else if (*del < '0' || *del > '9') + break; + } + + strlcpy2(base_version, haproxy_version, del - haproxy_version + 1); + if (dots < 2) + printf("Known bugs: https://github.com/haproxy/haproxy/issues?q=is:issue+is:open\n"); + else + printf("Known bugs: " PRODUCT_URL_BUGS "\n", base_version); + } } static void display_build_opts()