From a2bd014395b6745a39114fd4c78cec6cc19e26b9 Mon Sep 17 00:00:00 2001 From: Julien Castelain Date: Tue, 14 May 2019 15:11:26 +0200 Subject: [PATCH 1/3] chore: update .gitmodule configuration --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 0d76bc07bc..df292e2a1f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "ckeditor-dev"] - ignore = dirty + ignore = all path = ckeditor-dev url = https://github.com/ckeditor/ckeditor-dev.git From 52106db2fa283efa7cb26d99898d7f684ecb7e59 Mon Sep 17 00:00:00 2001 From: Julien Castelain Date: Tue, 14 May 2019 15:12:40 +0200 Subject: [PATCH 2/3] feat: add update command ...and also fixed some formatting issues --- ck.sh | 155 +++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 105 insertions(+), 50 deletions(-) diff --git a/ck.sh b/ck.sh index 7f1f527698..4c3b4a41ff 100755 --- a/ck.sh +++ b/ck.sh @@ -15,13 +15,15 @@ function init() { } function usage() { - echo "Usage: ck.sh COMMAND" + echo + echo "Usage: ck.sh COMMAND [OPTIONS]" echo echo " Where COMMAND is either:" echo echo " ๐Ÿ”ง setup: Setup everything to start working on a patch" echo " ๐Ÿ’‰ patch: Generate patches " echo " ๐Ÿ”ฅ build: Generate a patched version of CKEditor" + echo " ๐ŸŒถ update \$VERSION: Update the ckeditor-dev submodule to \$VERSION" echo echo } @@ -37,13 +39,11 @@ COMMAND=$1 case "$COMMAND" in build) echo - echo "*---------------------------------------------------------*" - echo "| โš ๏ธ WARNING |" - echo "*---------------------------------------------------------*" + echo "โš ๏ธ WARNING" echo echo "This will generate a patched version of CKEditor" - read -p "Are you sure you want to continue? [y/n]" yn + read -p "Are you sure you want to continue?[y/n] " yn case $yn in [Yy]*) @@ -56,7 +56,7 @@ case "$COMMAND" in echo "Checking for existing patches" echo - if ! ls ../patches/*; then + if ! ls ../patches/*.patch; then echo "There doesn't seem to be any patch" fi @@ -66,7 +66,7 @@ case "$COMMAND" in if ! git am ../patches/*; then echo - echo "โš ๏ธ There was a problem applying patches:" + echo "โŒ There was a problem applying patches:" echo echo "To retry manually and fix:" echo @@ -74,7 +74,7 @@ case "$COMMAND" in echo " git am --abort" echo " git am ../patches/*" echo - echo "Once you are happy with the result, run `sh ck.sh patch` to update the contents of \"patches/\"." + echo "Once you are happy with the result, run 'sh ck.sh patch' to update the contents of \"patches/\"." echo exit 1 fi @@ -93,9 +93,7 @@ case "$COMMAND" in cp -r dev/builder/release/ckeditor/* ../ckeditor/ echo - echo "*---------------------------------------------------------*" - echo "| โœ… DONE |" - echo "*---------------------------------------------------------*" + echo "โœ… DONE" echo echo "Don't forget to commit the result!" echo @@ -119,37 +117,33 @@ case "$COMMAND" in # Check for the existence of the liferay branch in the submodule if ! git rev-parse --verify liferay &>/dev/null; then echo - echo "*---------------------------------------------------------*" - echo "| โŒ ERROR |" - echo "*---------------------------------------------------------*" + echo "โŒ ERROR" echo - echo "It seems that there's no `liferay` branch in the `ckeditor-dev` submodule." + echo "It seems that there's no 'liferay' branch in the 'ckeditor-dev' submodule." echo - echo "Please run `sh ck.sh setup` to set up everything correctly." + echo "Please run 'sh ck.sh setup' to set up everything correctly." echo - exit 1 fi git checkout liferay --quiet # Check for existing patches - patches=$(find ../patches -name *.patch -type f) - - if [[ $(echo "$patches" | wc -l) -ne 0 ]]; then + if ! ls ../patches/*.patch &>/dev/null ; then echo - echo "*---------------------------------------------------------*" - echo "| โš ๏ธ WARNING |" - echo "*---------------------------------------------------------*" + echo "No patches found." echo + else + echo + echo "โš ๏ธ WARNING" echo echo "This will replace any existing patches..." echo - echo "$patches" + ls -l ../patches/*.patch echo # Prompt the user to confirm he wants to delete existing patches - read -p "Are you sure you want to continue [y/n]? " yn + read -p "Are you sure you want to continue?[y/n] " yn case $yn in [Yy]*) echo @@ -163,13 +157,8 @@ case "$COMMAND" in echo echo "Aborting." echo - exit 1 ;; esac - else - echo - echo "No patches found." - echo fi echo "Generating patches." @@ -178,41 +167,107 @@ case "$COMMAND" in git format-patch $sha1 -o ../patches echo - echo "*---------------------------------------------------------*" - echo "| โœ… DONE |" - echo "*---------------------------------------------------------*" - echo + echo "โœ… DONE" echo echo "You can now build CKEditor with your patches." echo - echo echo "Here are the steps to follow:" echo - echo "1. Run `sh ./ck.sh build` to generate a patched version." + echo "1. Run 'sh ck.sh build' to generate a patched version." echo ;; setup) - init - git checkout --detach HEAD - git branch -f liferay HEAD - git checkout liferay - echo - echo "*---------------------------------------------------------*" - echo "| โœ… DONE |" - echo "*---------------------------------------------------------*" + echo "โš ๏ธ WARNING" echo + echo "โ— This will reset any changes you currently have in the 'ckeditor-dev' submodule" echo - echo "You can now start working on your patch(es)." echo + read -p "Are you sure you want to continue?[y/n] " yn + case $yn in + [Yy]*) + init + git checkout --detach HEAD --quiet + git branch -f liferay HEAD + git checkout liferay --quiet + + echo + echo "โœ… DONE" + echo + echo + echo "You can now start working on your patch(es)." + echo + echo + echo "Here are the steps to follow:" + echo + echo "1. Navigate to the ckeditor-dev submodule directory ('cd ckeditor-dev')" + echo "2.ย Work on your changes" + echo "3. Commit your changes" + echo "4. Run 'sh ck.sh patch' to generate the patches" + echo + ;; + *) + echo + echo "Aborting." + echo + ;; + esac + ;; + update) + git submodule update --init + cd ckeditor-dev + git fetch + echo - echo "Here are the steps to follow:" + echo "Listing current tags: " + + tags=$(git tag -l --sort=creatordate | grep -v ee- | grep -v liferay | \ + sort -t. -k 1,1nr -k 2,2nr -k 3,3nr -k 4,4nr | head -6) + + echo "$tags" + echo + + read -p "Please enter the tag you want to update to: " tag + + if ! git describe --exact-match --tags $tag &>/dev/null ; then + echo + echo "โŒ ERROR" + echo + echo "Sorry, the \`$tag\` tag does not exist." + echo + exit 1 + fi + + echo - echo "1. Navigate to the ckeditor-dev submodule directory (`cd ckeditor-dev`)" - echo "2.ย Work on your changes" - echo "3. Commit your changes" - echo "4. Run `sh ck.sh patch` to generate the patches" + echo "โš ๏ธ WARNING" echo + echo "This will update the \`ckeditor-dev\` submodule to point to the $tag tag" + echo + + read -p "Are you sure you want to continue?[y/n] " yn + case $yn in + [Yy]*) + git reset --hard HEAD + git clean -fdx + git checkout "$tag" + + commitmsg=$(git log --oneline | head -1) + + cd .. + git add ckeditor-dev + git commit -m "Update ckeditor-dev to $commitmsg" + + echo + echo "โœ… DONE" + echo + ;; + *) + echo + echo "Aborting." + echo + ;; + esac ;; *) usage From 58a928c3231952e55518a38bb73ef7a7fb22c65d Mon Sep 17 00:00:00 2001 From: Julien Castelain Date: Thu, 16 May 2019 14:24:37 +0200 Subject: [PATCH 3/3] chore: Capture signals --- ck.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ck.sh b/ck.sh index 4c3b4a41ff..b4a85893b5 100755 --- a/ck.sh +++ b/ck.sh @@ -34,6 +34,8 @@ if [ $# -ne 1 ]; then exit 1 fi +trap "echo \"\n\nAborting.\n\"; exit" SIGHUP SIGINT SIGTERM + COMMAND=$1 case "$COMMAND" in