Skip to content

Commit d3a3fba

Browse files
committed
Merge pull request #11 from s0undt3ch/develop
Attempt to initially shallow clone Salt's repository
2 parents d7dd65a + 368ddf7 commit d3a3fba

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
Version 2014.07.29:
2+
* Shallow clone Salt's repository for speed improvements. In case of failure, resume old
3+
behaviour.
24
* Fixed bug introduced in 0577622 when salt-api service install and checks were added
35
* Distro Support Fixed:
46
* Fixed infinite loop when handling RHEL dependencies. Thanks Dan Mick(@dmick).

bootstrap-salt.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,19 +1111,26 @@ __git_clone_and_checkout() {
11111111
[ -d /tmp/git ] || mkdir /tmp/git
11121112
cd /tmp/git
11131113
if [ -d $SALT_GIT_CHECKOUT_DIR ]; then
1114+
echodebug "Found a checked out Salt repository"
11141115
cd $SALT_GIT_CHECKOUT_DIR
1116+
echodebug "Fetching git changes"
11151117
git fetch || return 1
11161118
# Tags are needed because of salt's versioning, also fetch that
1119+
echodebug "Fetching git tags"
11171120
git fetch --tags || return 1
11181121

11191122
# If we have the SaltStack remote set as upstream, we also need to fetch the tags from there
11201123
if [ "$(git remote -v | grep $_SALTSTACK_REPO_URL)" != "" ]; then
1124+
echodebug "Fetching upstream(SaltStack's Salt repository) git tags"
11211125
git fetch --tags upstream
11221126
else
1127+
echoinfo "Adding SaltStack's Salt repository as a remote"
11231128
git remote add upstream "$_SALTSTACK_REPO_URL"
1129+
echodebug "Fetching upstream(SaltStack's Salt repository) git tags"
11241130
git fetch --tags upstream
11251131
fi
11261132

1133+
echodebug "Hard reseting the cloned repository to ${GIT_REV}"
11271134
git reset --hard "$GIT_REV" || return 1
11281135

11291136
# Just calling `git reset --hard $GIT_REV` on a branch name that has
@@ -1133,21 +1140,37 @@ __git_clone_and_checkout() {
11331140
# changes.
11341141
git branch -a | grep -q "${GIT_REV}"
11351142
if [ $? -eq 0 ]; then
1143+
echodebug "Rebasing the cloned repository branch"
11361144
git pull --rebase || return 1
11371145
fi
11381146
else
1147+
# Let's try shallow cloning to speed up
1148+
echoinfo "Attempting to shallow clone Salt's repository from ${_SALT_REPO_URL}"
1149+
git clone --depth 1 --branch "$GIT_REV" "$_SALT_REPO_URL"
1150+
if [ $? -eq 0 ]; then
1151+
cd "$SALT_GIT_CHECKOUT_DIR"
1152+
return 0
1153+
fi
1154+
1155+
# Shallow clone above failed(missing upstream tags???), let's resume the old behaviour.
1156+
echowarn "Failed to shallow clone."
1157+
echoinfo "Resuming regular git clone and remote SaltStack repository addition procedure"
11391158
git clone "$_SALT_REPO_URL" || return 1
11401159
cd "$SALT_GIT_CHECKOUT_DIR"
11411160

11421161
if [ "$_SALT_REPO_URL" != "$_SALTSTACK_REPO_URL" ]; then
11431162
# We need to add the saltstack repository as a remote and fetch tags for proper versioning
1163+
echoinfo "Adding SaltStack's Salt repository as a remote"
11441164
git remote add upstream "$_SALTSTACK_REPO_URL"
1165+
echodebug "Fetching upstream(SaltStack's Salt repository) git tags"
11451166
git fetch --tags upstream
11461167
fi
11471168

1169+
echodebug "Checking out $GIT_REV"
11481170
git checkout "$GIT_REV" || return 1
11491171

11501172
fi
1173+
echoinfo "Cloning Salt's git repository succeeded"
11511174
return 0
11521175
}
11531176

0 commit comments

Comments
 (0)