Fix archive script bugs (#5860)

This commit is contained in:
Misty Stanley-Jones 2018-01-29 17:39:20 -08:00 committed by GitHub
parent 08e7715762
commit 6ddec7eef0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 12 deletions

View File

@ -3,10 +3,8 @@
while getopts ":hv:s:" opt; do while getopts ":hv:s:" opt; do
case ${opt} in case ${opt} in
v ) version="$OPTARG" v ) version="$OPTARG"
break
;; ;;
s ) SHA="$OPTARG" s ) SHA="$OPTARG"
break
;; ;;
\? ) echo "Usage: $0 [-h] | -v <docker-version> -s <GIT-SHA-OF-ARCHIVE>" \? ) echo "Usage: $0 [-h] | -v <docker-version> -s <GIT-SHA-OF-ARCHIVE>"
echo "" echo ""
@ -48,9 +46,9 @@ fi
## Make sure our working branch is clean ## Make sure our working branch is clean
BRANCH_STATUS=$(git diff --cached --exit-code) BRANCH_STATUS=$(git diff --cached --exit-code)
BRANCH_STATUS_UNTRACKED=$(git ls-files --other --directory --exclude-standard) BRANCH_STATUS_UNTRACKED=$(git ls-files --other --directory --exclude-standard | head -n 1)
if ! [ -z $BRANCH_STATUS -a -z $BRANCH_STATUS_UNTRACKED ]; then if [ $BRANCH_STATUS -o "$BRANCH_STATUS_UNTRACKED" ]; then
echo "Branch has uncommitted changes or untracked files. Exiting to protect you." echo "Branch has uncommitted changes or untracked files. Exiting to protect you."
echo "Use a fresh clone for this, not your normal working clone." echo "Use a fresh clone for this, not your normal working clone."
echo "If you don't want to set up all your remotes again," echo "If you don't want to set up all your remotes again,"
@ -66,7 +64,7 @@ git pull -q
git checkout -q ${SHA} git checkout -q ${SHA}
status=$? status=$?
if [ $status !- 0 ]; then if [ $status -ne 0 ]; then
echo "Failed to check out $SHA. Exiting." echo "Failed to check out $SHA. Exiting."
exit 1 exit 1
fi fi
@ -117,28 +115,35 @@ echo " /samples/ entries except /samples/ itself."
echo " A valid example for samples would look like:" echo " A valid example for samples would look like:"
cat << EOF cat << EOF
samples: samples:
- sectiontitle: Sample applications - sectiontitle: Sample applications
section: section:
- path: /samples/ - path: /samples/
title: Samples home title: Samples home
EOF EOF
echo " Do this for the following sections:" echo " Do this for the following sections:"
for dir in "${only_live_contents[@]}"; do for dir in "${only_live_contents[@]}"; do
echo " \/$dir\/" echo " /$dir/"
done done
echo
echo "2. Do a local build and run to test your archive." echo "2. Do a local build and run to test your archive."
echo " docker build -t archivetest ." echo " docker build -t archivetest ."
echo " docker run --rm -it -p 4000:4000 archivetest" echo " docker run --rm -it -p 4000:4000 archivetest"
echo "3. After carefully reviewing the output of `git status` to make sure no" echo "3. After carefully reviewing the output of 'git status' to make sure no"
echo " files are being added by mistake, Run the following to add and commit" echo " files are being added by mistake, Run the following to add and commit"
echo " all your changes, including new files:" echo " all your changes, including new files:"
echo " git commit -m \"Created archive branch v$version\" -A" echo " git commit -m \"Created archive branch v$version\" -A"
echo "4. Push your archive to the upstream remote:" echo "4. Push your archive to the upstream remote:"
echo " git push upstream v$version" echo " git push upstream v$version"
echo
echo "99. If you want to bail out of this operation completely,"
echo " and get back to master, run the following:"
echo
echo " git reset --hard; git clean -fd; git checkout master; git branch -D v$version"
echo