From d782b00711ddb3925738626e5509191932164975 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 17 Sep 2013 00:59:37 +0100 Subject: [PATCH 1/5] Added git branch and revision to development builds --- Makefile.am | 65 ++++++++++++++++++++++++++---------------------- configure.ac | 9 +++++++ src/ui/console.c | 12 +++++++++ 3 files changed, 56 insertions(+), 30 deletions(-) diff --git a/Makefile.am b/Makefile.am index 45d8a9c0..9a4c96d5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,33 +1,18 @@ -bin_PROGRAMS = profanity -profanity_SOURCES = \ - src/contact.c src/contact.h src/log.c src/common.c \ - src/log.h src/profanity.c src/common.h \ - src/main.c src/profanity.h src/chat_session.c \ - src/chat_session.h src/muc.c src/muc.h src/jid.h src/jid.c \ - src/resource.c src/resource.h \ - src/xmpp/xmpp.h src/xmpp/capabilities.c src/xmpp/connection.c \ - src/xmpp/iq.c src/xmpp/message.c src/xmpp/presence.c src/xmpp/stanza.c \ - src/xmpp/stanza.h src/xmpp/message.h src/xmpp/iq.h src/xmpp/presence.h \ - src/xmpp/capabilities.h src/xmpp/connection.h \ - src/xmpp/roster.c src/xmpp/roster.h \ - src/xmpp/bookmark.c src/xmpp/bookmark.h \ - src/ui/ui.h src/ui/window.c src/ui/window.h src/ui/core.c \ - src/ui/titlebar.c src/ui/statusbar.c src/ui/inputwin.c \ - src/ui/console.c src/ui/notifier.c src/ui/notifier.h \ - src/ui/windows.c src/ui/windows.h \ - src/command/command.h src/command/command.c src/command/history.c \ - src/command/history.h src/tools/parser.c \ - src/tools/parser.h \ - src/tools/autocomplete.c src/tools/autocomplete.h \ - src/tools/history.c src/tools/history.h \ - src/tools/tinyurl.c src/tools/tinyurl.h \ - src/config/accounts.c src/config/accounts.h \ - src/config/preferences.c src/config/preferences.h \ - src/config/theme.c src/config/theme.h +if INCLUDE_GIT_VERSION +src/gitversion.c: .git/HEAD .git/index + rm -f src/gitversion.c src/gitversion.o + echo "#ifndef PROF_GIT_BRANCH" >> $@ + echo "#define PROF_GIT_BRANCH \"$(shell git rev-parse --symbolic-full-name --abbrev-ref HEAD)\"" >> $@ + echo "#endif" >> $@ + echo "#ifndef PROF_GIT_REVISION" >> $@ + echo "#define PROF_GIT_REVISION \"$(shell git log --pretty=format:'%h' -n 1)\"" >> $@ + echo "#endif" >> $@ -TESTS = tests/testsuite -check_PROGRAMS = tests/testsuite -tests_testsuite_SOURCES = \ +clean-local: + rm -f src/gitversion.c src/gitversion.o +endif + +core_sources = \ src/contact.c src/contact.h src/log.c src/common.c \ src/log.h src/profanity.c src/common.h \ src/profanity.h src/chat_session.c \ @@ -51,10 +36,30 @@ tests_testsuite_SOURCES = \ src/tools/tinyurl.c src/tools/tinyurl.h \ src/config/accounts.c src/config/accounts.h \ src/config/preferences.c src/config/preferences.h \ - src/config/theme.c src/config/theme.h \ + src/config/theme.c src/config/theme.h + +test_sources = \ tests/test_roster.c tests/test_common.c tests/test_history.c \ tests/test_autocomplete.c tests/testsuite.c tests/test_parser.c \ tests/test_jid.c + +main_source = src/main.c + +git_sources = \ + src/gitversion.c + +if INCLUDE_GIT_VERSION +with_git_sources = $(git_sources) $(core_sources) +else +with_git_sources = $(core_sources) +endif + +bin_PROGRAMS = profanity +profanity_SOURCES = $(main_source) $(with_git_sources) + +TESTS = tests/testsuite +check_PROGRAMS = tests/testsuite +tests_testsuite_SOURCES = $(with_git_sources) $(test_sources) tests_testsuite_LDADD = -lheadunit -lstdc++ man_MANS = docs/profanity.1 diff --git a/configure.ac b/configure.ac index a30c96d8..8468792c 100644 --- a/configure.ac +++ b/configure.ac @@ -4,6 +4,15 @@ AC_PREREQ([2.65]) AC_INIT([profanity], [0.4.0], [boothj5web@gmail.com]) PACKAGE_STATUS="development" + +## get git branch and revision if in development +if test "x$PACKAGE_STATUS" = xdevelopment; then + AM_CONDITIONAL([INCLUDE_GIT_VERSION], [true]) + AC_DEFINE_UNQUOTED([HAVE_GIT_VERSION], [1], [Include git info]) +else + AM_CONDITIONAL([INCLUDE_GIT_VERSION], [false]) +fi + AC_DEFINE_UNQUOTED([PACKAGE_STATUS], ["$PACKAGE_STATUS"], [Status of this build]) AC_CONFIG_SRCDIR([src/main.c]) AC_CONFIG_HEADERS([src/config.h]) diff --git a/src/ui/console.c b/src/ui/console.c index fe15d73f..17e97ca3 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -40,6 +40,10 @@ #include "xmpp/xmpp.h" #include "xmpp/bookmark.h" +#ifdef HAVE_GIT_VERSION +#include "gitversion.c" +#endif + static void _cons_splash_logo(void); void _show_roster_contacts(GSList *list, gboolean show_groups); @@ -167,7 +171,11 @@ cons_about(void) win_print_time(console, '-'); if (strcmp(PACKAGE_STATUS, "development") == 0) { +#ifdef HAVE_GIT_VERSION + wprintw(console->win, "Welcome to Profanity, version %sdev.%s.%s\n", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); +#else wprintw(console->win, "Welcome to Profanity, version %sdev\n", PACKAGE_VERSION); +#endif } else { wprintw(console->win, "Welcome to Profanity, version %s\n", PACKAGE_VERSION); } @@ -1395,7 +1403,11 @@ _cons_splash_logo(void) wprintw(console->win, "\n"); win_print_time(console, '-'); if (strcmp(PACKAGE_STATUS, "development") == 0) { +#ifdef HAVE_GIT_VERSION + wprintw(console->win, "Version %sdev.%s.%s\n", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); +#else wprintw(console->win, "Version %sdev\n", PACKAGE_VERSION); +#endif } else { wprintw(console->win, "Version %s\n", PACKAGE_VERSION); } From 6b852a2f0f3df20702e44b1f6068661673ae9e3c Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 17 Sep 2013 01:08:12 +0100 Subject: [PATCH 2/5] Include git revision with -v output --- Makefile.am | 2 +- src/main.c | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 9a4c96d5..9da258eb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -55,7 +55,7 @@ with_git_sources = $(core_sources) endif bin_PROGRAMS = profanity -profanity_SOURCES = $(main_source) $(with_git_sources) +profanity_SOURCES = $(with_git_sources) $(main_source) TESTS = tests/testsuite check_PROGRAMS = tests/testsuite diff --git a/src/main.c b/src/main.c index 99f71351..253c9237 100644 --- a/src/main.c +++ b/src/main.c @@ -19,10 +19,13 @@ * along with Profanity. If not, see . * */ - +#include #include #include "config.h" +#ifdef HAVE_GIT_VERSION +#include "gitversion.c" +#endif #include "profanity.h" @@ -55,7 +58,17 @@ main(int argc, char **argv) g_option_context_free(context); if (version == TRUE) { - g_print("Profanity, version %s\n", PACKAGE_VERSION); + + if (strcmp(PACKAGE_STATUS, "development") == 0) { +#ifdef HAVE_GIT_VERSION + g_print("Profanity, version %sdev.%s.%s\n", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); +#else + g_print("Profanity, version %sdev\n", PACKAGE_VERSION); +#endif + } else { + g_print("Profanity, version %s\n", PACKAGE_VERSION); + } + g_print("Copyright (C) 2012, 2013 James Booth <%s>.\n", PACKAGE_BUGREPORT); g_print("License GPLv3+: GNU GPL version 3 or later \n"); g_print("\n"); From a15dbdf7ff35ffb126188aa063695b67a813ca84 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 17 Sep 2013 01:11:38 +0100 Subject: [PATCH 3/5] Force git revision update on make --- Makefile.am | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 9da258eb..7e8ee456 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,8 @@ if INCLUDE_GIT_VERSION -src/gitversion.c: .git/HEAD .git/index + +FORCE: + +src/gitversion.c: .git/HEAD .git/index FORCE rm -f src/gitversion.c src/gitversion.o echo "#ifndef PROF_GIT_BRANCH" >> $@ echo "#define PROF_GIT_BRANCH \"$(shell git rev-parse --symbolic-full-name --abbrev-ref HEAD)\"" >> $@ From 90d5df9ef7c83066251e8e02dae33441f8bb0a4b Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 17 Sep 2013 01:12:43 +0100 Subject: [PATCH 4/5] Added gitversion.c to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6c29afec..1c5662be 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ core bugs/ TODO plugins/ +src/gitversion.c From ee8ff948bfc1a21a10ea7e5bb34fffde781624e6 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 17 Sep 2013 01:28:35 +0100 Subject: [PATCH 5/5] Use git revision in development strings --- src/profanity.c | 10 +++++++++- src/ui/core.c | 11 +++++++++++ src/xmpp/capabilities.c | 11 +++++++++++ src/xmpp/iq.c | 11 +++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/profanity.c b/src/profanity.c index 4e9e887c..b18cbe91 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -22,6 +22,10 @@ #include "config.h" +#ifdef HAVE_GIT_VERSION +#include "gitversion.c" +#endif + #include #include #include @@ -615,7 +619,11 @@ _init(const int disable_tls, char *log_level) log_level_t prof_log_level = log_level_from_string(log_level); log_init(prof_log_level); if (strcmp(PACKAGE_STATUS, "development") == 0) { - log_info("Starting Profanity (%sdev)...", PACKAGE_VERSION); +#ifdef HAVE_GIT_VERSION + log_info("Starting Profanity (%sdev.%s.%s)...", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); +#else + log_info("Starting Profanity (%sdev)...", PACKAGE_VERSION); +#endif } else { log_info("Starting Profanity (%s)...", PACKAGE_VERSION); } diff --git a/src/ui/core.c b/src/ui/core.c index 16c1d2ff..6b415a2b 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -22,6 +22,10 @@ #include "config.h" +#ifdef HAVE_GIT_VERSION +#include "gitversion.c" +#endif + #include #include #ifdef HAVE_LIBXSS @@ -1375,7 +1379,14 @@ _ui_draw_win_title(void) g_string_append(version_str, " "); g_string_append(version_str, PACKAGE_VERSION); if (strcmp(PACKAGE_STATUS, "development") == 0) { +#ifdef HAVE_GIT_VERSION + g_string_append(version_str, "dev."); + g_string_append(version_str, PROF_GIT_BRANCH); + g_string_append(version_str, "."); + g_string_append(version_str, PROF_GIT_REVISION); +#else g_string_append(version_str, "dev"); +#endif } } diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c index f38a2749..658be124 100644 --- a/src/xmpp/capabilities.c +++ b/src/xmpp/capabilities.c @@ -22,6 +22,10 @@ #include "config.h" +#ifdef HAVE_GIT_VERSION +#include "gitversion.c" +#endif + #include #include @@ -238,7 +242,14 @@ caps_create_query_response_stanza(xmpp_ctx_t * const ctx) GString *name_str = g_string_new("Profanity "); g_string_append(name_str, PACKAGE_VERSION); if (strcmp(PACKAGE_STATUS, "development") == 0) { +#ifdef HAVE_GIT_VERSION + g_string_append(name_str, "dev."); + g_string_append(name_str, PROF_GIT_BRANCH); + g_string_append(name_str, "."); + g_string_append(name_str, PROF_GIT_REVISION); +#else g_string_append(name_str, "dev"); +#endif } xmpp_stanza_set_attribute(identity, "name", name_str->str); diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 8eb4d99e..1ddfcb34 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -22,6 +22,10 @@ #include "config.h" +#ifdef HAVE_GIT_VERSION +#include "gitversion.c" +#endif + #include #include @@ -236,7 +240,14 @@ _iq_handle_version_get(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, xmpp_stanza_t *version_txt = xmpp_stanza_new(ctx); GString *version_str = g_string_new(PACKAGE_VERSION); if (strcmp(PACKAGE_STATUS, "development") == 0) { +#ifdef HAVE_GIT_VERSION + g_string_append(version_str, "dev."); + g_string_append(version_str, PROF_GIT_BRANCH); + g_string_append(version_str, "."); + g_string_append(version_str, PROF_GIT_REVISION); +#else g_string_append(version_str, "dev"); +#endif } xmpp_stanza_set_text(version_txt, version_str->str); xmpp_stanza_add_child(version, version_txt);