diff --git a/README.md b/README.md index 9143991..f53f1a6 100644 --- a/README.md +++ b/README.md @@ -813,6 +813,7 @@ file (platform-dependent defaults are left empty below): signature=0 tab_size=8 terminal_title= + top_bar_show_version=0 unread_indicator=N ### attachment_indicator diff --git a/make.sh b/make.sh index dc51f72..fea5423 100755 --- a/make.sh +++ b/make.sh @@ -22,6 +22,7 @@ TESTS="0" DOC="0" INSTALL="0" SRC="0" +BUMP="0" case "${1%/}" in deps) DEPS="1" @@ -54,6 +55,10 @@ case "${1%/}" in SRC="1" ;; + bump) + BUMP="1" + ;; + all) DEPS="1" BUILD="1" @@ -72,6 +77,7 @@ case "${1%/}" in echo " install - perform build and install" echo " all - perform deps, build, tests, doc and install" echo " src - perform source code reformatting" + echo " bump - perform version bump" exit 1 ;; esac @@ -118,6 +124,37 @@ if [[ "${SRC}" == "1" ]]; then exiterr "unrustify failed, exiting." fi +# bump +if [[ "${BUMP}" == "1" ]]; then + CURRENT_VERSION=$(grep NMAIL_VERSION src/version.cpp | head -1 | awk -F'"' '{print $2}') # ex: 5.1.1 + CURRENT_MAJMIN="$(echo ${CURRENT_VERSION} | cut -d'.' -f1,2)" # ex: 5.1 + URL="https://github.com/d99kris/nmail.git" + LATEST_TAG=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' ${URL} | tail -n1 | cut -d'/' -f3) + LATEST_VERSION=$(echo "${LATEST_TAG}" | cut -c2-) # ex: 5.1.3 + LATEST_MAJMIN="$(echo ${LATEST_VERSION} | cut -d'.' -f1,2)" # ex: 5.1 + SED="sed" + if [[ "$(uname)" == "Darwin" ]]; then + SED="gsed" + fi + if [[ "${CURRENT_MAJMIN}" == "${LATEST_MAJMIN}" ]]; then + NEW_MAJ="$(echo ${CURRENT_VERSION} | cut -d'.' -f1)" # ex: 5 + let NEW_MIN=$(echo ${CURRENT_VERSION} | cut -d'.' -f2)+1 + NEW_PATCH="1" # use 1-based build/snapshot number + NEW_VERSION="${NEW_MAJ}.${NEW_MIN}.${NEW_PATCH}" + echo "Current: ${CURRENT_MAJMIN} == ${LATEST_MAJMIN} Latest" + echo "Bump release: ${NEW_VERSION}" + ${SED} -i "s/^#define NMAIL_VERSION .*/#define NMAIL_VERSION \"${NEW_VERSION}\"/g" src/version.cpp + else + NEW_MAJ="$(echo ${CURRENT_VERSION} | cut -d'.' -f1)" # ex: 5 + NEW_MIN="$(echo ${CURRENT_VERSION} | cut -d'.' -f2)" # ex: 1 + let NEW_PATCH=$(echo ${CURRENT_VERSION} | cut -d'.' -f3)+1 + NEW_VERSION="${NEW_MAJ}.${NEW_MIN}.${NEW_PATCH}" + echo "Current: ${CURRENT_MAJMIN} != ${LATEST_MAJMIN} Latest" + echo "Bump build: ${NEW_VERSION}" + ${SED} -i "s/^#define NMAIL_VERSION .*/#define NMAIL_VERSION \"${NEW_VERSION}\"/g" src/version.cpp + fi +fi + # build if [[ "${BUILD}" == "1" ]]; then OS="$(uname)" diff --git a/src/main.cpp b/src/main.cpp index cf38f13..a9630da 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -149,7 +149,7 @@ int main(int argc, char* argv[]) THREAD_REGISTER(); Util::InitAppSignalHandlers(); - const std::string appVersion = Version::GetUiAppVersion(); + const std::string appVersion = Version::GetAppName(true /*p_WithVersion*/); LOG_INFO("%s", appVersion.c_str()); std::string osArch = Util::GetOsArch(); LOG_INFO("%s", osArch.c_str()); @@ -511,7 +511,7 @@ static void ShowHelp() static void ShowVersion() { std::cout << - Version::GetUiAppVersion() << "\n" + Version::GetAppName(true /*p_WithVersion*/) << "\n" "\n" "Copyright (c) 2019-2024 Kristofer Berggren\n" "\n" diff --git a/src/nmail.1 b/src/nmail.1 index fecc2b2..7ff507d 100644 --- a/src/nmail.1 +++ b/src/nmail.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man. -.TH NMAIL "1" "June 2024" "nmail v4.72" "User Commands" +.TH NMAIL "1" "June 2024" "nmail 5.1.1" "User Commands" .SH NAME nmail \- ncurses mail .SH SYNOPSIS diff --git a/src/ui.cpp b/src/ui.cpp index 35ee3d0..6839be5 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -157,6 +157,7 @@ void Ui::Init() { "localized_subject_prefixes", "" }, { "signature", "0" }, { "terminal_title", "" }, + { "top_bar_show_version", "0" }, }; const std::string configPath(Util::GetApplicationDir() + std::string("ui.conf")); m_Config = Config(configPath, defaultConfig); @@ -356,6 +357,7 @@ void Ui::Init() m_SearchShowFolder = m_Config.Get("search_show_folder") == "1"; Util::SetLocalizedSubjectPrefixes(m_Config.Get("localized_subject_prefixes")); m_Signature = m_Config.Get("signature") == "1"; + m_TopBarShowVersion = m_Config.Get("top_bar_show_version") == "1"; try { @@ -527,8 +529,8 @@ void Ui::DrawTop() werase(m_TopWin); wattron(m_TopWin, m_AttrsTopBar); - std::string version = " " + Version::GetUiAppVersion(); - std::string topLeft = Util::TrimPadString(version, (m_ScreenWidth - 13) / 2); + static const std::string appName = " " + Version::GetAppName(m_TopBarShowVersion); + std::string topLeft = Util::TrimPadString(appName, (m_ScreenWidth - 13) / 2); std::string status = GetStatusStr(); std::string topRight = status + " "; int centerWidth = m_ScreenWidth - (int)topLeft.size() - (int)topRight.size() - 2; diff --git a/src/ui.h b/src/ui.h index 0a2484d..c843e40 100644 --- a/src/ui.h +++ b/src/ui.h @@ -430,6 +430,7 @@ class Ui bool m_ShowFullHeader = false; bool m_SearchShowFolder = false; bool m_Signature = false; + bool m_TopBarShowVersion = false; std::string m_TerminalTitle; diff --git a/src/version.cpp b/src/version.cpp index e331587..a8e621a 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -7,7 +7,7 @@ #include "version.h" -#define NMAIL_VERSION "4.72" +#define NMAIL_VERSION "5.1.1" std::string Version::GetBuildOs() { @@ -39,14 +39,7 @@ std::string Version::GetCompiler() #endif } -std::string Version::GetMessageIdAppVersion() +std::string Version::GetAppName(bool p_WithVersion) { - static std::string version = "nmail." NMAIL_VERSION; - return version; -} - -std::string Version::GetUiAppVersion() -{ - static std::string version = "nmail v" NMAIL_VERSION; - return version; + return std::string("nmail") + (p_WithVersion ? " " NMAIL_VERSION : ""); } diff --git a/src/version.h b/src/version.h index c824a3d..3bdae79 100644 --- a/src/version.h +++ b/src/version.h @@ -1,6 +1,6 @@ // version.h // -// Copyright (c) 2022 Kristofer Berggren +// Copyright (c) 2022-2024 Kristofer Berggren // All rights reserved. // // nmail is distributed under the MIT license, see LICENSE for details. @@ -14,6 +14,5 @@ class Version public: static std::string GetBuildOs(); static std::string GetCompiler(); - static std::string GetMessageIdAppVersion(); - static std::string GetUiAppVersion(); + static std::string GetAppName(bool p_WithVersion); };