diff --git a/CMakeLists.txt b/CMakeLists.txt index 78e3c7997..340715e78 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,6 +106,30 @@ git_describe(GIT_DESC --always --long --dirty) git_branch_name(GIT_BRANCH) string(TIMESTAMP BUILD_DATE "%Y-%m-%d %H:%M:%S") +# Get current remote name and branch +execute_process( + COMMAND git rev-parse --abbrev-ref --symbolic-full-name @{u} + OUTPUT_VARIABLE GIT_REMOTE_NAME + RESULT_VARIABLE GIT_BRANCH_RESULT + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +# Default to origin if branch is not set +if (GIT_BRANCH_RESULT OR GIT_REMOTE_NAME STREQUAL "") + set(GIT_REMOTE_NAME "origin") +else() + # Extract remote name from full name + string(FIND "${GIT_REMOTE_NAME}" "/" INDEX) + string(SUBSTRING "${GIT_REMOTE_NAME}" 0 "${INDEX}" GIT_REMOTE_NAME) +endif() + +# Get remote link +execute_process( + COMMAND git config --get remote.${GIT_REMOTE_NAME}.url + OUTPUT_VARIABLE GIT_REMOTE_URL + OUTPUT_STRIP_TRAILING_WHITESPACE +) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/common/scm_rev.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/src/common/scm_rev.cpp" @ONLY) find_package(Boost 1.84.0 CONFIG) diff --git a/src/common/scm_rev.cpp.in b/src/common/scm_rev.cpp.in index 642e6373d..2de04e0be 100644 --- a/src/common/scm_rev.cpp.in +++ b/src/common/scm_rev.cpp.in @@ -6,14 +6,18 @@ #define GIT_REV "@GIT_REV@" #define GIT_BRANCH "@GIT_BRANCH@" #define GIT_DESC "@GIT_DESC@" +#define GIT_REMOTE_NAME "@GIT_REMOTE_NAME@" +#define GIT_REMOTE_URL "@GIT_REMOTE_URL@" #define BUILD_DATE "@BUILD_DATE@" namespace Common { -const char g_scm_rev[] = GIT_REV; -const char g_scm_branch[] = GIT_BRANCH; -const char g_scm_desc[] = GIT_DESC; -const char g_scm_date[] = BUILD_DATE; +const char g_scm_rev[] = GIT_REV; +const char g_scm_branch[] = GIT_BRANCH; +const char g_scm_desc[] = GIT_DESC; +const char g_scm_remote_name[] = GIT_REMOTE_NAME; +const char g_scm_remote_url[] = GIT_REMOTE_URL; +const char g_scm_date[] = BUILD_DATE; } // namespace diff --git a/src/common/scm_rev.h b/src/common/scm_rev.h index 005099d2d..f38efff42 100644 --- a/src/common/scm_rev.h +++ b/src/common/scm_rev.h @@ -8,6 +8,8 @@ namespace Common { extern const char g_scm_rev[]; extern const char g_scm_branch[]; extern const char g_scm_desc[]; +extern const char g_scm_remote_name[]; +extern const char g_scm_remote_url[]; extern const char g_scm_date[]; } // namespace Common diff --git a/src/emulator.cpp b/src/emulator.cpp index 81c4d814d..3ab26d484 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -57,6 +57,7 @@ Emulator::Emulator() { LOG_INFO(Loader, "Revision {}", Common::g_scm_rev); LOG_INFO(Loader, "Branch {}", Common::g_scm_branch); LOG_INFO(Loader, "Description {}", Common::g_scm_desc); + LOG_INFO(Loader, "Remote {}", Common::g_scm_remote_url); LOG_INFO(Config, "General LogType: {}", Config::getLogType()); LOG_INFO(Config, "General isNeo: {}", Config::isNeoModeConsole()); @@ -199,8 +200,15 @@ void Emulator::Run(const std::filesystem::path& file, const std::vector( Config::getScreenWidth(), Config::getScreenHeight(), controller, window_title); diff --git a/src/qt_gui/main_window.cpp b/src/qt_gui/main_window.cpp index 3678b3a82..ce7b7b19e 100644 --- a/src/qt_gui/main_window.cpp +++ b/src/qt_gui/main_window.cpp @@ -57,8 +57,15 @@ bool MainWindow::Init() { if (Common::isRelease) { window_title = fmt::format("shadPS4 v{}", Common::VERSION); } else { - window_title = fmt::format("shadPS4 v{} {} {}", Common::VERSION, Common::g_scm_branch, - Common::g_scm_desc); + std::string remote_url(Common::g_scm_remote_url); + if (remote_url == "https://github.com/shadps4-emu/shadPS4.git") { + window_title = fmt::format("shadPS4 v{} {} {}", Common::VERSION, Common::g_scm_branch, + Common::g_scm_desc); + } else { + std::string remote_host = remote_url.substr(19, remote_url.rfind('/') - 19); + window_title = fmt::format("shadPS4 v{} {}/{} {}", Common::VERSION, remote_host, + Common::g_scm_branch, Common::g_scm_desc); + } } setWindowTitle(QString::fromStdString(window_title)); this->show();