@@ -5,21 +5,22 @@ usage ()
55{
66 cat << EOT
77
8- ${0##*/ }
9- This script will download and create a CakePHP "core" folder for
10- the version number specified as the command line argument in
11- whatever folder it lives in. You must relocate this script to its
12- own directory where it can spawn new folders for each Cake version
13- without interfering with a git repo. This should be somewhere
14- central on your system where all Cake projects can symlink to the
8+ ${0##*/ }
9+ This script will download and create a CakePHP "core" folder for
10+ the version number specified as the command line argument in
11+ whatever folder it lives in. You must relocate this script to its
12+ own directory where it can spawn new folders for each Cake version
13+ without interfering with a git repo. This should be somewhere
14+ central on your system where all Cake projects can symlink to the
1515 individual Cake version required.
1616
1717Usage:
18- bin/${0##*/ } x.y.z [-f]
19-
20- Pass a CakePHP release number as the first argument.
21-
22- Specify '-f' as the second argument to forcibly replace the
18+ cakes/${0##*/ } x.y[.z] [-f]
19+
20+ Pass a CakePHP release number (or major.minor for latest) as
21+ the first argument.
22+
23+ Specify '-f' as the second argument to forcibly replace the
2324 cakephp repo.
2425
2526
@@ -31,7 +32,6 @@ if [ "$1" = '-h' ]; then
3132 usage
3233fi
3334
34-
3535umask a+rw
3636
3737DIR=" $( cd -P " $( dirname " $0 " ) " > /dev/null 2>&1 && pwd ) " ;
@@ -45,7 +45,7 @@ if [ "$2" = '-f' ]; then
4545fi
4646
4747
48- # Just a little precaution since this script comes bundled in the
48+ # Just a little precaution since this script comes bundled in the
4949# CakePHP-Skeleton's bin/ folder, but should't be used from there.
5050if [ " ${DIR##*/ } " = ' bin' ]; then
5151 echo " !!! The script has detected you are trying to run it from the bin/ folder."
@@ -58,15 +58,6 @@ if [ -n "$1" ]; then
5858else
5959 usage
6060fi
61- DESTDIR=" ${DIR} /cake_${TAG} "
62-
63- # Automatically replace an existing copy of the version.
64- if [ -d " ${DESTDIR} " ]; then
65- echo " ## Recreating Cake core v${TAG} " >&2
66- rm -rf ${DESTDIR}
67- else
68- echo " ## Creating Cake core v${TAG} " >&2
69- fi
7061
7162# If configured, reuse the existing temp folder (if present).
7263if [ $REUSE_REPO -gt 0 ] && [ -d " ${TMPDIR} " ]; then
@@ -87,13 +78,31 @@ echo "## Fetching updates from remote." >&2
8778cd ${TMPDIR}
8879git fetch
8980
81+ # "Fill in" the full version number if we were only given a major and minor.
82+ NUM_DOTS=$( tr -dc ' .' <<< " $TAG" | awk ' { print length; }' )
83+ if [ $NUM_DOTS -lt 2 ]; then
84+ echo " ## Determining latest point release." >&2
85+ POINTRELEASE=$( git tag -l | grep " ^${TAG} [0-9\.]*$" | sed " s/${TAG} \.//" | sort -n | tail -1 )
86+ TAG=" ${TAG} .${POINTRELEASE} "
87+ fi
88+
9089echo " ## Verifying requested tag: ${TAG} " >&2
91- git show-ref --tags --quiet --verify -- " refs/tags/$1 "
90+ git show-ref --tags --quiet --verify -- " refs/tags/${TAG} "
9291if [ $? -ne 0 ]; then
93- echo " !! Tag does not exist in the repo. Please check your input and try again."
92+ echo " !! Tag ' $TAG ' does not exist in the repo. Please check your input and try again."
9493 exit 1
9594fi
9695
96+ DESTDIR=" ${DIR} /cake_${TAG} "
97+
98+ # Automatically replace an existing copy of the version.
99+ if [ -d " ${DESTDIR} " ]; then
100+ echo " ## Recreating Cake core v${TAG} " >&2
101+ rm -rf ${DESTDIR}
102+ else
103+ echo " ## Creating Cake core v${TAG} " >&2
104+ fi
105+
97106echo " ## Staging snapshot." >&2
98107mkdir ${DESTDIR}
99108git archive $TAG --format=zip > archive.zip
0 commit comments