-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Patch workflow for ckeditor #17
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could combine all three scripts into one and use
./scripts/patch.sh
with an argument like:sh ./scripts/patch.sh init|create|build
?
This is a splendid idea. I'd say though it should be only two scripts/subcommands and not three. The "init" one should be an implicit thing that happens automatically if you haven't done it yet.
@wincent, I'm happier with the result than I was yesterday but still need your help to review when you can. Obviously, this is not foolproof (i.e. I can still delete the patches directory and try to run build which will fail at the moment) so I could probably improve a thing or two, but I think it will still be more useful than having to do everything manually. Thanks again for the help! |
Nice to have
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. Especially the emoji. I've left some comments but I think you should feel free to merge this whenever you consider it ready; we can always add more commits later if we identify improvements or bugs.
README.md
Outdated
sh ck.sh patch | ||
``` | ||
|
||
7. Create a build of CKEditor containing the patches: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the rendered output, this is "6". You could update this (and the following one) to match, or leave it. Depends on whether you care more about minimizing effort or making the source Markdown as readable/correct as possible. For example, some people always just make every numbered list item "1." in Markdown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's interesting ... good point
As for the "fix" , I habe my doubts, I can always update it since this is easy enought, but it might be better to use bullet points? For example, in two months we might discover that there is a missing step and we'll have to "update" everything again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, that's exactly why some people write numbered lists like this in Markdown:
1. first
1. second
1. third
In the words of the immortal(?) John Gruber himself:
The point is, if you want to, you can use ordinal numbers in your ordered Markdown lists, so that the numbers in your source match the numbers in your published HTML. But if you want to be lazy, you don’t have to.
I don't really know what the right answer is. In general, I like being lazy, but I always felt weird numbering things as "1.", "1.", "1." etc so I never did it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like being lazy too
ck.sh
Outdated
function message() { | ||
if [[ ! -z "$1" ]] ; then | ||
echo | ||
printf -- '-%.0s' {1..80}; echo "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#fancy
ck.sh
Outdated
# Save SHA1 for later | ||
sha1=`git submodule | grep ckeditor-dev | awk '{print $1}' | sed -e s/[^0-9a-f]//` | ||
|
||
# CD into the right place |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment seems a bit redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
ck.sh
Outdated
git checkout liferay --quiet | ||
|
||
# Check for existing patches | ||
if ls ../patches/* &>/dev/null; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you wanted to be stricter here you could look for files named *.patch
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! I'll update that.
ck.sh
Outdated
message "⚠️ WARNING" "$str" | ||
|
||
echo | ||
echo "$(ls ../patches/*)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this the same as just?
ls ../patches/*
(Although I'd suggest ../patches/*.patch
instead.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is. I'll fix that.
echo | ||
|
||
# Prompt the user to confirm he wants to delete existing patches | ||
read -p "Are you sure you want to continue [y/n]? " yn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again because init
is destructive, we might want to do the prompting a bit earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok yes seems better
ck.sh
Outdated
usage | ||
;; | ||
esac | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like an extra line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome!
ck.sh
Outdated
echo "Don't forget to commit the result!" | ||
echo | ||
echo "git add -A -- ckeditor" | ||
echo "git commit -m 'Update CKEDITOR'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor nit; what would be an example of a good commit message here? If we can show one automatically, great; otherwise we should probably leave it off (your instruction to "commit the result" is probably enough). I just don't want the history to wind up with a bunch of messages that all say "Update CKEDITOR", because you'll have to look at the commits (which may be large) in order to figure out what that actually means.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome!
Thanks
I just don't want the history to wind up with a bunch of messages that all say "Update CKEDITOR", because you'll have to look at the commits (which may be large) in order to figure out what that actually means.
Yes that's a good point.
ck.sh
Outdated
# Check arguments | ||
if [ $# -ne 1 ]; then | ||
usage | ||
exit 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good catch
README.md
Outdated
sh ck.sh patch | ||
``` | ||
|
||
7. Create a build of CKEditor containing the patches: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
README.md
Outdated
sh ck.sh patch | ||
``` | ||
|
||
7. Create a build of CKEditor containing the patches: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like being lazy too
ck.sh
Outdated
|
||
if [[ ! -z "$2" ]] ; then | ||
echo | ||
echo "$2" | fold -w 80 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's my take on this: Since we're assuming that Windows users have git
and all the wonderful tools that are required to use it, they will most probably be using Git for Windows, which comes with Git Bash (it's probably fancier than calling this msys2, mingw32 or however it is officially called) and it has all the *nix utilities like cat
, find
, fold
, uniq
... that might change with Microsoft planning to ship a Linux kernel with Windows.
In anycase you're right, if we have to, we could re-write this in JavaScript and make use of our good old friend child_process
.
echo | ||
echo " 🔧 setup: Setup everything to start working on a patch" | ||
echo " 💉 patch: Generate patches " | ||
echo " 🔥 build: Generate a patched version of CKEditor" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
ck.sh
Outdated
git checkout liferay --quiet | ||
|
||
# Check for existing patches | ||
if ls ../patches/* &>/dev/null; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! I'll update that.
ck.sh
Outdated
message "⚠️ WARNING" "$str" | ||
|
||
echo | ||
echo "$(ls ../patches/*)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is. I'll fix that.
ck.sh
Outdated
usage | ||
;; | ||
esac | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, correct
echo | ||
|
||
# Prompt the user to confirm he wants to delete existing patches | ||
read -p "Are you sure you want to continue [y/n]? " yn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok yes seems better
ck.sh
Outdated
if ! git rev-parse --verify liferay &>/dev/null; then | ||
str=$(printf "%s" | ||
"It seems that there's no *liferay* branch in the *ckeditor-dev* submodule.\n\n" \ | ||
"Please run *sh ./ck.sh setup* to set up.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, after thinking more about this I actually think they key here is:
Again here, wouldn't just multiple echo calls be simpler and more readable?
And my answer would be
Yes, this message
function is probably a good attempt at not repeating code, but it's way too #fancy and doesn't work with multiline input. So I'll use echo
.
@wincent, This is a first attempt at writing a patch workflow for ckeditor ... so please don't be afraid at what you're about to see 🙈😱
I thought adding this info in the README was the right thing to do.
There's probably an issue with the way the patches are generated but that's why I'm asking you for a review.
Maybe we could combine all three scripts into one and use
./scripts/patch.sh
with an argument like:sh ./scripts/patch.sh init|create|build
?Tell me what you think when you can.
Thanks!
EDIT: Once I'll have made the required changes for this to work properly, I'll apply the first patch