diff --git a/CMakeLists.txt b/CMakeLists.txt index 340715e78..e10fcfb98 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,21 +106,27 @@ 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 +# Try to get the upstream remote and branch execute_process( COMMAND git rev-parse --abbrev-ref --symbolic-full-name @{u} OUTPUT_VARIABLE GIT_REMOTE_NAME RESULT_VARIABLE GIT_BRANCH_RESULT + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE ) -# Default to origin if branch is not set +# Default to origin if there's no upstream set or if the command failed if (GIT_BRANCH_RESULT OR GIT_REMOTE_NAME STREQUAL "") set(GIT_REMOTE_NAME "origin") else() - # Extract remote name from full name + # Extract remote name if the output contains a remote/branch format string(FIND "${GIT_REMOTE_NAME}" "/" INDEX) - string(SUBSTRING "${GIT_REMOTE_NAME}" 0 "${INDEX}" GIT_REMOTE_NAME) + if (INDEX GREATER -1) + string(SUBSTRING "${GIT_REMOTE_NAME}" 0 "${INDEX}" GIT_REMOTE_NAME) + else() + # If no remote is present (only a branch name), default to origin + set(GIT_REMOTE_NAME "origin") + endif() endif() # Get remote link diff --git a/src/emulator.cpp b/src/emulator.cpp index 3ab26d484..ba8d8917c 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -201,7 +201,8 @@ void Emulator::Run(const std::filesystem::path& file, const std::vector