appmeshworkshop icon indicating copy to clipboard operation
appmeshworkshop copied to clipboard

Crystal add_time_ms.patch - "patch does not apply" error

Open gpertzov opened this issue 4 years ago • 1 comments

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

gpertzov avatar Jul 09 '20 16:07 gpertzov

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

jeeslo avatar Jul 29 '20 15:07 jeeslo