Skip to content

Commit

Permalink
update-tracker.sh: handling of 'admin' directory
Browse files Browse the repository at this point in the history
The new process now check if there are untracked files in the repo. If
yes, ask user if changes should be discarded, and abort if not.

Then at end of script, the user is asked if 'admin' dir should be
deleted.

This is easier to implement than a new commit in the local branch to
remove the directory, because this way we don't have to deal with
potential merge conflicts which would be difficult to handle in an
automated way.

Fixes #16345
  • Loading branch information
dregad committed Jan 9, 2014
2 parents 941a2b1 + a4c6e9a commit da485c8
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions update-trackers.sh
Expand Up @@ -47,7 +47,12 @@ function usage() {


function process_error() {
echo "ERROR: $1"
echo -ne "\nERROR: "
if [ -n "$1" ]
then
echo $1
fi

if [ -n "$REPO" ]
then
echo "Fix issues in repository '$REPO' and try again"
Expand Down Expand Up @@ -113,6 +118,22 @@ do
cd $DIR_NAME/$REPO 2>/dev/null ||
process_error "repository '$REPO' does not exist in '$DIR_NAME' or is not accessible"

# Detect if there are unstaged changes in the repository's current branch
git diff-index --name-status --exit-code HEAD
if [ $? -ne 0 ]
then
echo -e "\nThere are unstaged changes"
read -n 1 -p "Would you like to discard them ? "
echo
if [ "$(echo ${REPLY} | tr "[:upper:]" "[:lower:]")" = "y" ]
then
echo "Discarding changes"
git checkout -- . || process_error
else
process_error "can't proceed with unstaged changes"
fi
fi

# First update the reference branch, pull changes from upstream
echo "- Pulling upstream changes into reference branch '$UPDATE_BRANCH'"
git checkout $UPDATE_BRANCH ||
Expand Down Expand Up @@ -145,16 +166,28 @@ do
grep "^\s*\$g_version_suffix" $CONFIG_FILE >/dev/null
if [ $? -eq 0 ]
then
echo "Updating existing config"
echo "Updating existing config file"
sed -r -i.bak "s/^(\s*\\\$g_version_suffix\s*=\s*[\"']).*([\"'])/\1$VERSION_SUFFIX\2/" $CONFIG_FILE
else
echo "Config option does not exist, appending it to end of file"
echo "\$g_version_suffix = '$VERSION_SUFFIX';" >>$CONFIG_FILE
fi

# Syntax check the modified config file, just in case
php -l $CONFIG_FILE ||
process_error "Invalid $CONFIG_FILE"

echo
read -n 1 -p "The 'admin' directory should be deleted. Would you like to do it now ? "
echo
ADMIN_DIR=$PWD/admin
if [ "$(echo ${REPLY} | tr "[:upper:]" "[:lower:]")" = "y" ]
then
rm -rvf $ADMIN_DIR
else
echo "WARNING: Remember to delete it after completing the upgrade (rm -rf $ADMIN_DIR)"
fi

echo -e "\nRepository '$REPO' updated successfully\n"
cd - >/dev/null
done

0 comments on commit da485c8

Please sign in to comment.