mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-14 08:12:16 +00:00
Fork detection: Fix PR actions only showing HEAD as the branch name (#2697)
* I'd be very surprised if this works 1st try * More logging and cleanup * Minor fixes
This commit is contained in:
parent
c96853816a
commit
602de0c370
1 changed files with 22 additions and 8 deletions
|
@ -113,28 +113,39 @@ git_describe(GIT_DESC --always --long --dirty)
|
||||||
git_branch_name(GIT_BRANCH)
|
git_branch_name(GIT_BRANCH)
|
||||||
string(TIMESTAMP BUILD_DATE "%Y-%m-%d %H:%M:%S")
|
string(TIMESTAMP BUILD_DATE "%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
|
message("start git things")
|
||||||
# Try to get the upstream remote and branch
|
# Try to get the upstream remote and branch
|
||||||
|
message("check for remote and branch")
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND git rev-parse --abbrev-ref --symbolic-full-name @{u}
|
COMMAND git rev-parse --abbrev-ref --symbolic-full-name @{u}
|
||||||
OUTPUT_VARIABLE GIT_REMOTE_NAME
|
OUTPUT_VARIABLE GIT_REMOTE_NAME
|
||||||
RESULT_VARIABLE GIT_BRANCH_RESULT
|
RESULT_VARIABLE GIT_REMOTE_RESULT
|
||||||
ERROR_QUIET
|
ERROR_QUIET
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
)
|
)
|
||||||
|
|
||||||
# If there's no upstream set or the command failed, check remote.pushDefault
|
# If there's no upstream set or the command failed, check remote.pushDefault
|
||||||
if (GIT_BRANCH_RESULT OR GIT_REMOTE_NAME STREQUAL "")
|
if (GIT_REMOTE_RESULT OR GIT_REMOTE_NAME STREQUAL "")
|
||||||
|
message("check default push")
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND git config --get remote.pushDefault
|
COMMAND git config --get remote.pushDefault
|
||||||
OUTPUT_VARIABLE GIT_REMOTE_NAME
|
OUTPUT_VARIABLE GIT_REMOTE_NAME
|
||||||
RESULT_VARIABLE GIT_PUSH_DEFAULT_RESULT
|
RESULT_VARIABLE GIT_REMOTE_RESULT
|
||||||
ERROR_QUIET
|
ERROR_QUIET
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
# If remote.pushDefault is not set or fails, default to origin
|
# If running in GitHub Actions and the above fails
|
||||||
if (GIT_PUSH_DEFAULT_RESULT OR GIT_REMOTE_NAME STREQUAL "")
|
if (GIT_REMOTE_RESULT OR GIT_REMOTE_NAME STREQUAL "")
|
||||||
|
message("check github")
|
||||||
set(GIT_REMOTE_NAME "origin")
|
set(GIT_REMOTE_NAME "origin")
|
||||||
|
|
||||||
|
if (DEFINED ENV{GITHUB_HEAD_REF}) # PR branch name
|
||||||
|
set(GIT_BRANCH "pr-$ENV{GITHUB_HEAD_REF}")
|
||||||
|
elseif (DEFINED ENV{GITHUB_REF}) # Normal branch name
|
||||||
|
string(REGEX REPLACE "^refs/[^/]*/" "" GIT_BRANCH "$ENV{GITHUB_REF}")
|
||||||
|
else()
|
||||||
|
message("couldn't find branch")
|
||||||
|
set(GIT_BRANCH "detached-head")
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
# Extract remote name if the output contains a remote/branch format
|
# Extract remote name if the output contains a remote/branch format
|
||||||
|
@ -148,6 +159,7 @@ else()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Get remote link
|
# Get remote link
|
||||||
|
message("getting remote link")
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND git config --get remote.${GIT_REMOTE_NAME}.url
|
COMMAND git config --get remote.${GIT_REMOTE_NAME}.url
|
||||||
OUTPUT_VARIABLE GIT_REMOTE_URL
|
OUTPUT_VARIABLE GIT_REMOTE_URL
|
||||||
|
@ -156,6 +168,8 @@ execute_process(
|
||||||
|
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/common/scm_rev.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/src/common/scm_rev.cpp" @ONLY)
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/common/scm_rev.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/src/common/scm_rev.cpp" @ONLY)
|
||||||
|
|
||||||
|
message("end git things, remote: ${GIT_REMOTE_NAME}, branch: ${GIT_BRANCH}")
|
||||||
|
|
||||||
find_package(Boost 1.84.0 CONFIG)
|
find_package(Boost 1.84.0 CONFIG)
|
||||||
find_package(FFmpeg 5.1.2 MODULE)
|
find_package(FFmpeg 5.1.2 MODULE)
|
||||||
find_package(fmt 10.2.0 CONFIG)
|
find_package(fmt 10.2.0 CONFIG)
|
||||||
|
|
Loading…
Add table
Reference in a new issue