From 8b5cda7f735449b62742a17d70f67b276e37efaa Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Thu, 30 Mar 2023 13:59:38 +0200 Subject: [PATCH] After clone: fetch the reposiry again, follwed by a git reset --hard. The effect is that git crates all diretories and files in /etc and /opt. --- git_helpers | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/git_helpers b/git_helpers index 8f2531a..b9729a6 100755 --- a/git_helpers +++ b/git_helpers @@ -89,18 +89,30 @@ clone_customer_repository () { if cd ${CUSTOMER_ID_BASE_DIR}; then # local res=$(exec_git_command git --git-dir=.git --work-tree=/ init) exec_git_command git checkout "$LOCAL_BRANCH" - exec_git_command git config core.worktree "/" if [[ $? -eq 0 ]]; then - # re-initialized. copy post-merge (a hook called - # when 'git pull' is executed and changed data - # are received). - if cp ".githooks/post-merge" ".git/hooks"; then - log_debug "$func:${LINENO} copied post-merge to .git/hooks" - CLONE_CUSTOMER_REPOSITORY=true - log_debug "$func:${LINENO} re-init of ${1} done" - cd_home; return 0 + log_debug "$func:${LINENO} checked out local branch $LOCAL_BRANCH" + exec_git_command git config core.worktree "/" + if [[ $? -eq 0 ]]; then + log_debug "$func:${LINENO} configured worktree" + exec_git_command git fetch --all + if [[ $? -eq 0 ]]; then + log_debug "$func:${LINENO} fetch repository" + exec_git_command git reset --hard "$LOCAL_BRANCH" + if [[ $? -eq 0 ]]; then + log_debug "$func:${LINENO} reset --hard $LOCAL_BRANCH" + # re-initialized. copy post-merge (a hook called + # when 'git pull' is executed and changed data + # are received). + if cp ".githooks/post-merge" ".git/hooks"; then + log_debug "$func:${LINENO} copied post-merge to .git/hooks" + CLONE_CUSTOMER_REPOSITORY=true + log_debug "$func:${LINENO} re-init of ${1} done" + cd_home; return 0 + fi + fi + fi fi - fi + fi fi fi cd_home; return 1