Skip to content

Commit 1641155

Browse files
fix(#551): fix issue with file deletion (#596)
Signed-off-by: Andy Augustin <[email protected]>
1 parent 574812a commit 1641155

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/sync_template.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ GIT_REMOTE_PULL_PARAMS="${GIT_REMOTE_PULL_PARAMS:---allow-unrelated-histories --
5555

5656
TEMPLATE_REMOTE_GIT_HASH=$(git ls-remote "${SOURCE_REPO}" HEAD | awk '{print $1}')
5757
SHORT_TEMPLATE_GIT_HASH=$(git rev-parse --short "${TEMPLATE_REMOTE_GIT_HASH}")
58+
LOCAL_CURRENT_GIT_HASH=$(git rev-parse HEAD) # need to be run before a pull to get the current local git hash
59+
60+
info "current git hash: ${LOCAL_CURRENT_GIT_HASH}"
5861

5962
export TEMPLATE_GIT_HASH=${SHORT_TEMPLATE_GIT_HASH}
6063
export PR_BRANCH="${PR_BRANCH_NAME_PREFIX}_${TEMPLATE_GIT_HASH}"
@@ -162,11 +165,13 @@ function check_staged_files_available_graceful_exit() {
162165

163166
#######################################
164167
# force source file deletion if they had been deleted
168+
# Arguments:
169+
# local_current_git_hash
165170
#######################################
166171
function force_delete_files() {
167172
info "force delete files"
168173
warn "force file deletion is enabled. Deleting files which are deleted within the target repository"
169-
local_current_git_hash=$(git rev-parse HEAD)
174+
local local_current_git_hash=$1
170175

171176
info "current git hash: ${local_current_git_hash}"
172177

@@ -435,7 +440,7 @@ function arr_checkout_branch_and_pull() {
435440
restore_templatesyncignore_file "${TEMPLATE_SYNC_IGNORE_FILE_PATH}"
436441

437442
if [ "$IS_FORCE_DELETION" == "true" ]; then
438-
force_delete_files
443+
force_delete_files "${LOCAL_CURRENT_GIT_HASH}"
439444
fi
440445

441446
echo "::endgroup::"

0 commit comments

Comments
 (0)