From 07c2da3863de8ad27f76456c4845d08c12a30539 Mon Sep 17 00:00:00 2001 From: eti-codefresh Date: Wed, 7 Jun 2023 16:00:22 +0300 Subject: [PATCH 1/5] support Git Clone depth with different branches --- service.yaml | 2 +- start.sh | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/service.yaml b/service.yaml index e7bf1a0..9bd68bc 100644 --- a/service.yaml +++ b/service.yaml @@ -1 +1 @@ -version: 10.1.19 +version: 10.1.20 diff --git a/start.sh b/start.sh index 9941ecf..74e0b5a 100644 --- a/start.sh +++ b/start.sh @@ -196,6 +196,10 @@ if [ -d "$CLONE_DIR" ]; then cd $CLONE_DIR if [ -n "$REVISION" ]; then + if [ -n "$DEPTH" ]; then + git_retry git remote set-branches origin '*' + git_retry git fetch --depth=$DEPTH + fi git_checkout fi fi @@ -204,7 +208,12 @@ else # Clone a fresh copy eval $GIT_COMMAND cd $CLONE_DIR + if [ -n "$REVISION" ]; then + if [ -n "$DEPTH" ]; then + git_retry git remote set-branches origin '*' + git_retry git fetch --depth=$DEPTH + fi git_checkout fi From 9c700062f0a31d5ad00bb6496dc3522f5a9b3c9d Mon Sep 17 00:00:00 2001 From: eti-codefresh Date: Thu, 8 Jun 2023 10:50:37 +0300 Subject: [PATCH 2/5] add logs --- start.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/start.sh b/start.sh index 74e0b5a..2aead6b 100644 --- a/start.sh +++ b/start.sh @@ -194,11 +194,15 @@ if [ -d "$CLONE_DIR" ]; then rm -rf $CLONE_DIR eval $GIT_COMMAND cd $CLONE_DIR - + echo 'cloned successfully' if [ -n "$REVISION" ]; then if [ -n "$DEPTH" ]; then + echo 'git remote set-branches origin '*' - before' git_retry git remote set-branches origin '*' + echo 'git remote set-branches origin '*' - after' + echo 'git fetch --depth=$DEPTH' git_retry git fetch --depth=$DEPTH + echo 'git fetch --depth=$DEPTH - after' fi git_checkout fi @@ -208,11 +212,15 @@ else # Clone a fresh copy eval $GIT_COMMAND cd $CLONE_DIR - + echo 'cloned successfully' if [ -n "$REVISION" ]; then if [ -n "$DEPTH" ]; then + echo 'git remote set-branches origin '*' - before' git_retry git remote set-branches origin '*' + echo 'git remote set-branches origin '*' - after' + echo 'git fetch --depth=$DEPTH' git_retry git fetch --depth=$DEPTH + echo 'git fetch --depth=$DEPTH - after' fi git_checkout fi From c13e8617bff957aabec3b8d03f3911602c533fc0 Mon Sep 17 00:00:00 2001 From: eti-codefresh Date: Thu, 8 Jun 2023 13:55:04 +0300 Subject: [PATCH 3/5] add logs --- start.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/start.sh b/start.sh index 2aead6b..acfd3db 100644 --- a/start.sh +++ b/start.sh @@ -194,7 +194,7 @@ if [ -d "$CLONE_DIR" ]; then rm -rf $CLONE_DIR eval $GIT_COMMAND cd $CLONE_DIR - echo 'cloned successfully' + echo "The folder already exists but it is not a git repository - cloned successfully into $CLONE_DIR" if [ -n "$REVISION" ]; then if [ -n "$DEPTH" ]; then echo 'git remote set-branches origin '*' - before' @@ -212,13 +212,13 @@ else # Clone a fresh copy eval $GIT_COMMAND cd $CLONE_DIR - echo 'cloned successfully' + echo "cloned successfully into $CLONE_DIR" if [ -n "$REVISION" ]; then if [ -n "$DEPTH" ]; then echo 'git remote set-branches origin '*' - before' git_retry git remote set-branches origin '*' echo 'git remote set-branches origin '*' - after' - echo 'git fetch --depth=$DEPTH' + echo "git fetch --depth=$DEPTH" git_retry git fetch --depth=$DEPTH echo 'git fetch --depth=$DEPTH - after' fi From 36378fca0b2d110638b846b1e1c8a0273a50201a Mon Sep 17 00:00:00 2001 From: eti-codefresh Date: Sat, 10 Jun 2023 04:05:12 +0300 Subject: [PATCH 4/5] test --- start.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/start.sh b/start.sh index acfd3db..7454d03 100644 --- a/start.sh +++ b/start.sh @@ -215,12 +215,12 @@ else echo "cloned successfully into $CLONE_DIR" if [ -n "$REVISION" ]; then if [ -n "$DEPTH" ]; then - echo 'git remote set-branches origin '*' - before' - git_retry git remote set-branches origin '*' - echo 'git remote set-branches origin '*' - after' - echo "git fetch --depth=$DEPTH" - git_retry git fetch --depth=$DEPTH - echo 'git fetch --depth=$DEPTH - after' + git remote set-branches origin '*' + cat .git/config + git remote set-branches origin "*" + cat .git/config + + git fetch --depth=$DEPTH fi git_checkout fi From 5b8bd12f60054fe715edf6dbf38d3b7c970c2ef2 Mon Sep 17 00:00:00 2001 From: eti-codefresh Date: Sat, 10 Jun 2023 04:14:00 +0300 Subject: [PATCH 5/5] test --- start.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/start.sh b/start.sh index 7454d03..ec13375 100644 --- a/start.sh +++ b/start.sh @@ -215,12 +215,13 @@ else echo "cloned successfully into $CLONE_DIR" if [ -n "$REVISION" ]; then if [ -n "$DEPTH" ]; then - git remote set-branches origin '*' + git_retry git remote set-branches origin '*' cat .git/config - git remote set-branches origin "*" + git_retry git remote set-branches origin "*" cat .git/config - - git fetch --depth=$DEPTH + eval "git_retry git remote set-branches origin '*'" + cat .git/config + git_retry git fetch --depth=$DEPTH fi git_checkout fi