We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi.
Thanks for this library. It saved me lots of time. However, I'm currently facing a problem. The following code run indefinitely and eats RAM:
package main import ( "bytes" "github.com/bluekeyes/go-gitdiff/gitdiff" ) const ( diff = ` diff --git a/app/controllers/seances_controller.rb b/app/controllers/seances_controller.rb index 743d0ad..4f4d4e8 100644 --- a/app/controllers/seances_controller.rb +++ b/app/controllers/seances_controller.rb @@ -5,8 +5,6 @@ class SeancesController < ApplicationController if authorization_result.code != 200 return render_by_status_code(code: authorization_result.code, data: authorization_result.data) end - - render_by_status_code(code: 200, data: json) end def create ` ) var ( body = `class SeancesController < ApplicationController def index set_auth_operation_id_header if authorization_result.code != 200 return render_by_status_code(code: authorization_result.code, data: authorization_result.data) end render_by_status_code(code: 200, data: json) end def create seance = Seance.new( movie_id: params[:movie_id], price: params[:price], datetime: params[:datetime] ) if seance.save! render json: { data: { id: seance.id, type: 'seances', attributes: { datetime: seance.datetime, price: seance.price }, seats: Seat.pluck(:id).map do |seat_id| { id: seat_id, vacant: true } end } } end rescue ActiveRecord::RecordInvalid => e render_invalid_record(message: e.message) end def destroy ActiveRecord::Base.transaction do Booking.where(seance: params[:id]).destroy_all Seance.find(params[:id]).destroy end render json: { data: [{ id: params[:id], type: 'seances' }] } end def json seats_ids = Seat.pluck(:id) Seance.includes(:bookings).where(movie: params[:movie_id]).order('datetime').limit(params[:max_results] || 50).map do |seance| booking_seats_ids = seance.bookings.pluck(:seat_id) { id: seance.id, price: seance.price, datetime: seance.datetime, seats: seats_ids.map do |seat_id| { id: seat_id, vacant: !(booking_seats_ids.include?(seat_id)) } end } end end end ` ) func main() { files, _, err := gitdiff.Parse(bytes.NewBufferString(diff)) if err != nil { panic(err) } for _, file := range files { writer := bytes.NewBuffer(nil) reader := bytes.NewReader([]byte(body)) appl := gitdiff.NewApplier(reader) if err := appl.ApplyFile(writer, file); err != nil { panic(err) } } }
I debugged it to somewhere in Flush() operation. The internals keeps copying same lines over and over.
I would appreciate your help in debugging this. Ivan
The text was updated successfully, but these errors were encountered:
Thanks for reporting this with the self-contained reproduction. This is fixed in v0.2.1 and the code above completes without an error now.
Sorry, something went wrong.
Thank for a quick patch!
Successfully merging a pull request may close this issue.
Hi.
Thanks for this library. It saved me lots of time. However, I'm currently facing a problem.
The following code run indefinitely and eats RAM:
I debugged it to somewhere in Flush() operation. The internals keeps copying same lines over and over.
I would appreciate your help in debugging this.
Ivan
The text was updated successfully, but these errors were encountered: