Skip to content

Commit

Permalink
improve handling of revision string (#630)
Browse files Browse the repository at this point in the history
we use the same standard revision string as it is common at Snapcraft
the revision in the debug output is suppressed when there are no commits since the last tag
  • Loading branch information
mrbaseman authored Apr 8, 2020
1 parent 1814574 commit 2b5fdd3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
15 changes: 10 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ AC_GNU_SOURCE
m4_ifndef([PKG_PROG_PKG_CONFIG], [m4_fatal([Please install pkg-config.])])
PKG_PROG_PKG_CONFIG

AC_PATH_PROG(GIT, [git], [""], "$PATH:/sbin:/usr/sbin")
AS_IF([test "x$GIT" = "x"], [
REVISION=unavailable
], [
REVISION=`git describe --tags | sed -e 's/-/+git/;y/-/./'`
REVISION=""
AS_IF([test -d .git], [
AC_PATH_PROG(GIT, [git], [""], "$PATH:/sbin:/usr/sbin")
AS_IF([test "x$GIT" != "x"], [
REVISION=`$GIT describe --tags | sed -e 's/-/+git/;y/-/./'`
])
])
AS_IF([test "x$REVISION" = "x"], [
REVISION="unavailable"
])

AC_SUBST(REVISION)

# Helps support multiarch by setting 'host_os' and 'host_cpu'
Expand Down
5 changes: 4 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ int main(int argc, char **argv)
if (strcmp(long_options[option_index].name,
"version") == 0) {
printf(VERSION "\n");
if (strcmp(&REVISION[1], VERSION))
log_debug("revision " REVISION "\n");
ret = EXIT_SUCCESS;
goto exit;
}
Expand Down Expand Up @@ -518,7 +520,8 @@ int main(int argc, char **argv)
log_debug_all("ATTENTION: the output contains sensitive information such as the THE CLEAR TEXT PASSWORD.\n");

log_debug("openfortivpn " VERSION "\n");
log_debug(" revision " REVISION "\n");
if (strcmp(&REVISION[1], VERSION))
log_debug("revision " REVISION "\n");

// Load config file
if (config_file[0] != '\0') {
Expand Down

0 comments on commit 2b5fdd3

Please sign in to comment.