Skip to content

Commit

Permalink
internal: teach gather_pr_locally.cmake to create temp branch (skyrim…
Browse files Browse the repository at this point in the history
  • Loading branch information
Pospelove authored May 17, 2024
1 parent 3953c76 commit c0621c7
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions misc/gather_prs_locally.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ set(PSEUDO_BINARY_DIR "./build")

include(${CMAKE_SOURCE_DIR}/cmake/yarn.cmake)

message(STATUS "Downloading Pospelove/auto-merge-action@main (dist/index.js)")

message(STATUS "Downloading ${AUTO_MERGE_REPO}@${AUTO_MERGE_BRANCH} (dist/index.js)")

file(REMOVE_RECURSE ${PSEUDO_BINARY_DIR}/auto-merge-action)
Expand Down Expand Up @@ -67,6 +65,40 @@ else()
message(FATAL_ERROR "Failed to run Pospelove/auto-merge-action@main: ${NODE_OUTPUT}")
endif()

# if branch is main, then do git switch -c gather-prs-<timestamp>

execute_process(
COMMAND git branch --show-current
OUTPUT_VARIABLE CURRENT_BRANCH
RESULT_VARIABLE GIT_COMMIT_RESULT
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(NOT GIT_COMMIT_RESULT EQUAL 0)
message(FATAL_ERROR "Failed to get the current branch: ${GIT_COMMIT_RESULT} ${CURRENT_BRANCH}")
endif()

message(STATUS "Current branch: ${CURRENT_BRANCH}")

if(CURRENT_BRANCH MATCHES main)
message(STATUS "Main branch detected. Switching to a temporary branch")

string(TIMESTAMP TIMESTAMP "%Y%m%d%H%M%S")
set(TEMP_BRANCH "gather-prs-${TIMESTAMP}")

execute_process(
COMMAND git switch -c ${TEMP_BRANCH}
RESULT_VARIABLE GIT_SWITCH_RESULT
OUTPUT_VARIABLE GIT_SWITCH_OUTPUT
)

if(GIT_SWITCH_RESULT EQUAL 0)
message(STATUS "Switched to a temporary branch ${TEMP_BRANCH}")
else()
message(FATAL_ERROR "Failed to switch to a temporary branch: ${GIT_SWITCH_OUTPUT}")
endif()
endif()

# Commit the changes locally
# git add . && git commit -m "Gather PRs"

Expand Down

0 comments on commit c0621c7

Please sign in to comment.