appmeshworkshop
appmeshworkshop copied to clipboard
Crystal add_time_ms.patch - "patch does not apply" error
Applying add_time_ms.patch as appears in https://www.appmeshworkshop.com/deployment/updatecrystal/ Results in the "patch does not apply" error
workshop:~/environment $ git apply --stat ecsdemo-crystal/add_time_ms.patch
code_hash.txt | 2 +-
src/server.cr | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
workshop:~/environment $ git -C ~/environment/ecsdemo-crystal apply add_time_ms.patch
error: patch failed: src/server.cr:24
error: src/server.cr: patch does not apply
Hi,
After digging in, it looks like the patch file provided included some additional changes that were not marked as such, hence git apply command is throwing an error:
< elsif context.request.path == "/health"
< context.response.content_type = "text/plain"
< context.response.print "Healthy!"
< --
> elsif context.request.path == "/crystal/api" || context.request.path == "/crystal/api/"
> context.response.content_type = "application/json"
> context.response.print %Q({"from":"Crystal backend", "message": "#{az_message}", "commit": "#{code_hash.chomp}"})
> --
I will create a pull request to get this addressed. In the mean time, you could simply replace lines 49-51 in the add_time_ms.patch file with lines 29-31 from server.cr file:
elsif context.request.path == "/crystal/api" || context.request.path == "/crystal/api/"
context.response.content_type = "application/json"
context.response.print %Q({"from":"Crystal backend", "message": "#{az_message}", "commit": "#{code_hash.chomp}"})
Please note: the source file is using tabs while the patch is using spaces, so run the git apply command by adding the --ignore-whitespace switch:
git -C ~/environment/ecsdemo-crystal apply add_time_ms.patch --ignore-whitespace
Hope it helps