diff options
author | Gerald Combs <gerald@wireshark.org> | 2024-01-31 18:59:22 -0800 |
---|---|---|
committer | AndersBroman <a.broman58@gmail.com> | 2024-02-01 09:12:38 +0000 |
commit | 8a54995b1c3ca70575045ba9c59e7df9cbd1233a (patch) | |
tree | 1393b9326e892acb15ef42c0e67c1f2da775f13f | |
parent | ee90fb0f4160cbafa85bcc405c4d7f26991e8114 (diff) |
wsutil+tools: Version info updates
Define VCS_NUM_COMMITS and VCS_COMMIT_ID in vcs_version.h. Use them to
return the Logray version in get_lr_vcs_version_info and use that where
appropriate. Rename VCSVERSION to VCS_VERSION.
-rw-r--r-- | doc/README.developer | 2 | ||||
-rwxr-xr-x | tools/make-version.py | 29 | ||||
-rw-r--r-- | ui/logray/logray_main_window.cpp | 2 | ||||
-rw-r--r-- | ui/qt/about_dialog.cpp | 5 | ||||
-rw-r--r-- | ui/qt/capture_file_properties_dialog.cpp | 8 | ||||
-rw-r--r-- | ui/qt/welcome_page.cpp | 2 | ||||
-rw-r--r-- | wsutil/.editorconfig | 5 | ||||
-rw-r--r-- | wsutil/version_info.c | 18 | ||||
-rw-r--r-- | wsutil/version_info.h | 8 |
9 files changed, 58 insertions, 21 deletions
diff --git a/doc/README.developer b/doc/README.developer index cf0692d3a9..b6ac8ea0de 100644 --- a/doc/README.developer +++ b/doc/README.developer @@ -973,7 +973,7 @@ not toLocal8Bit() or toLatin1(). 8. Miscellaneous notes -Each commit in your branch corresponds to a different VCSVERSION string +Each commit in your branch corresponds to a different VCS_VERSION string automatically defined in the header 'vcs_version.h' during the build. If you happen to find it convenient to disable this feature it can be done using: diff --git a/tools/make-version.py b/tools/make-version.py index fdb4ff3a32..763bbc3476 100755 --- a/tools/make-version.py +++ b/tools/make-version.py @@ -184,33 +184,44 @@ def update_versioned_files(src_dir, set_version, repo_data): def generate_version_h(repo_data): # Generate new contents of version.h from repository data + num_commits_line = '#define VCS_NUM_COMMITS "0"\n' + + commit_id_line = '/* #undef VCS_COMMIT_ID */\n' + if not repo_data.get('enable_vcsversion'): - return "/* #undef VCSVERSION */\n" + return '/* #undef VCS_VERSION */\n' + num_commits_line + commit_id_line + + if repo_data.get('num_commits'): + num_commits_line = f'#define VCS_NUM_COMMITS "{int(repo_data["num_commits"])}"\n' + + if repo_data.get('commit_id'): + commit_id_line = f'#define VCS_COMMIT_ID "{repo_data["commit_id"]}"' if repo_data.get('git_description'): # Do not bother adding the git branch, the git describe output # normally contains the base tag and commit ID which is more # than sufficient to determine the actual source tree. - return f'#define VCSVERSION "{repo_data["git_description"]}"\n' + return f'#define VCS_VERSION "{repo_data["git_description"]}"\n' + num_commits_line + commit_id_line if repo_data.get('last_change') and repo_data.get('num_commits'): version_string = f"v{repo_data['version_major']}.{repo_data['version_minor']}.{repo_data['version_patch']}" - vcs_line = f'#define VCSVERSION "{version_string}-Git-{repo_data["num_commits"]}"\n' - return vcs_line + vcs_line = f'#define VCS_VERSION "{version_string}-Git-{repo_data["num_commits"]}"\n' + return vcs_line + num_commits_line + commit_id_line if repo_data.get('commit_id'): - vcs_line = f'#define VCSVERSION "Git commit {repo_data["commit_id"]}"\n' - return vcs_line + vcs_line = f'#define VCS_VERSION "Git commit {repo_data["commit_id"]}"\n' + return vcs_line + num_commits_line + commit_id_line + + vcs_line = '#define VCS_VERSION "Git Rev Unknown from unknown"\n' - vcs_line = '#define VCSVERSION "Git Rev Unknown from unknown"\n' - return vcs_line + return vcs_line + num_commits_line + commit_id_line def print_VCS_REVISION(version_file, repo_data, set_vcs): # Write the version control system's version to $version_file. # Don't change the file if it is not needed. # - # XXX - We might want to add VCSVERSION to CMakeLists.txt so that it can + # XXX - We might want to add VCS_VERSION to CMakeLists.txt so that it can # generate vcs_version.h independently. new_version_h = generate_version_h(repo_data) diff --git a/ui/logray/logray_main_window.cpp b/ui/logray/logray_main_window.cpp index b7b537383a..aef2eb4a07 100644 --- a/ui/logray/logray_main_window.cpp +++ b/ui/logray/logray_main_window.cpp @@ -2418,7 +2418,7 @@ void LograyMainWindow::setTitlebarForCaptureFile() QString LograyMainWindow::replaceWindowTitleVariables(QString title) { title.replace("%P", get_profile_name()); - title.replace("%V", get_ws_vcs_version_info()); + title.replace("%V", get_lr_vcs_version_info()); #ifdef HAVE_LIBPCAP if (global_commandline_info.capture_comments) { diff --git a/ui/qt/about_dialog.cpp b/ui/qt/about_dialog.cpp index 08cdad3788..0614221b56 100644 --- a/ui/qt/about_dialog.cpp +++ b/ui/qt/about_dialog.cpp @@ -30,10 +30,11 @@ #endif #include "ui/util.h" -#include <wsutil/utf8_entities.h> +#include "wsutil/filesystem.h" #include "wsutil/plugins.h" #include "wsutil/version_info.h" + #include "ui/capture_globals.h" #include "extcap.h" @@ -503,7 +504,7 @@ void AboutDialog::showEvent(QShowEvent * event) void AboutDialog::updateWiresharkText() { - QString vcs_version_info_str = get_ws_vcs_version_info(); + QString vcs_version_info_str = is_packet_configuration_namespace() ? get_ws_vcs_version_info() : get_lr_vcs_version_info(); QString copyright_info_str = get_copyright_info(); QString license_info_str = get_license_info(); QString comp_info_str = gstring_free_to_qbytearray(get_compiled_version_info(gather_wireshark_qt_compiled_info)); diff --git a/ui/qt/capture_file_properties_dialog.cpp b/ui/qt/capture_file_properties_dialog.cpp index 27a6ea972b..2ad33fa94e 100644 --- a/ui/qt/capture_file_properties_dialog.cpp +++ b/ui/qt/capture_file_properties_dialog.cpp @@ -17,6 +17,7 @@ #include "wiretap/secrets-types.h" +#include "wsutil/filesystem.h" #include "wsutil/str_util.h" #include "wsutil/utf8_entities.h" #include "wsutil/version_info.h" @@ -631,7 +632,12 @@ void CaptureFilePropertiesDialog::on_buttonBox_clicked(QAbstractButton *button) { if (button == ui->buttonBox->button(QDialogButtonBox::Apply)) { QClipboard *clipboard = QApplication::clipboard(); - QString details = tr("Created by Wireshark %1\n\n").arg(get_ws_vcs_version_info()); + QString details; + if (is_packet_configuration_namespace()) { + details = tr("Created by Wireshark %1\n\n").arg(get_ws_vcs_version_info()); + } else { + details = tr("Created by Logray %1\n\n").arg(get_lr_vcs_version_info()); + } details.append(ui->detailsTextEdit->toPlainText()); clipboard->setText(details); } else if (button == ui->buttonBox->button(QDialogButtonBox::Reset)) { diff --git a/ui/qt/welcome_page.cpp b/ui/qt/welcome_page.cpp index 7ffb8564cd..a312ccacd4 100644 --- a/ui/qt/welcome_page.cpp +++ b/ui/qt/welcome_page.cpp @@ -154,7 +154,7 @@ void WelcomePage::setReleaseLabel() full_release = tr("You are running Logray "); } } - full_release += get_ws_vcs_version_info(); + full_release += is_packet_configuration_namespace() ? get_ws_vcs_version_info() : get_lr_vcs_version_info(); full_release += "."; #ifdef HAVE_SOFTWARE_UPDATE if (prefs.gui_update_enabled) { diff --git a/wsutil/.editorconfig b/wsutil/.editorconfig index 78cac4382d..03257de7f9 100644 --- a/wsutil/.editorconfig +++ b/wsutil/.editorconfig @@ -97,8 +97,9 @@ indent_size = tab [type_util.[ch]] indent_size = 2 -[u3.[ch]] -indent_size = 2 +[version_info.[ch]] +indent_style = tab +indent_size = tab [ws_getopt.[ch]] indent_style = tab diff --git a/wsutil/version_info.c b/wsutil/version_info.c index ab450686cb..d28fff9acf 100644 --- a/wsutil/version_info.c +++ b/wsutil/version_info.c @@ -513,18 +513,28 @@ get_runtime_version_info(gather_feature_func gather_runtime) const char * get_ws_vcs_version_info(void) { -#ifdef VCSVERSION - return VERSION " (" VCSVERSION ")"; +#ifdef VCS_VERSION + return VERSION " (" VCS_VERSION ")"; #else return VERSION; #endif } const char * +get_lr_vcs_version_info(void) +{ +#ifdef VCS_COMMIT_ID + return LOG_VERSION " (" VCS_NUM_COMMITS "-" VCS_COMMIT_ID ")"; +#else + return LOG_VERSION; +#endif +} + +const char * get_ws_vcs_version_info_short(void) { -#ifdef VCSVERSION - return VCSVERSION; +#ifdef VCS_VERSION + return VCS_VERSION; #else return VERSION; #endif diff --git a/wsutil/version_info.h b/wsutil/version_info.h index 1285cd2c57..3134c2de2e 100644 --- a/wsutil/version_info.h +++ b/wsutil/version_info.h @@ -99,6 +99,14 @@ WS_DLL_PUBLIC const char *get_ws_vcs_version_info(void); /* + * Return a version number string for Logray, including, for builds + * from a tree checked out from Logray's version control system, + * something identifying what version was checked out. + */ +WS_DLL_PUBLIC +const char *get_lr_vcs_version_info(void); + +/* * Shorter version of get_ws_vcs_version_info(). */ WS_DLL_PUBLIC |