Commits fail if commit_email column has not been added
I think this relates to https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/21598. Today with master I attempted to:
- Create a new repo
- Populate it with a new file
- After I hit commit, I saw this:
NoMethodError - undefined method `b' for nil:NilClass:
lib/gitlab/git/user.rb:31:in `to_gitaly'
lib/gitlab/gitaly_client/operation_service.rb:321:in `user_commit_files_request_header'
lib/gitlab/gitaly_client/operation_service.rb:238:in `block in user_commit_files'
grpc-1.11.0-universal (darwin) src/ruby/lib/grpc/generic/active_call.rb:392:in `client_streamer'
grpc-1.11.0-universal (darwin) src/ruby/lib/grpc/generic/client_stub.rb:255:in `block in client_streamer'
grpc-1.11.0-universal (darwin) src/ruby/lib/grpc/generic/interceptors.rb:170:in `intercept!'
grpc-1.11.0-universal (darwin) src/ruby/lib/grpc/generic/client_stub.rb:254:in `client_streamer'
grpc-1.11.0-universal (darwin) src/ruby/lib/grpc/generic/service.rb:175:in `block (3 levels) in rpc_stub_class'
lib/gitlab/gitaly_client.rb:134:in `call'
lib/gitlab/gitaly_client/operation_service.rb:262:in `user_commit_files'
lib/gitlab/git/repository.rb:817:in `block in multi_action'
lib/gitlab/git/repository.rb:887:in `wrapped_gitaly_errors'
lib/gitlab/git/repository.rb:816:in `multi_action'
app/models/repository.rb:806:in `block in multi_action'
app/models/repository.rb:789:in `with_cache_hooks'
app/models/repository.rb:806:in `multi_action'
app/models/repository.rb:770:in `create_file'
app/services/files/create_service.rb:16:in `create_transformed_commit'
app/services/files/create_service.rb:10:in `create_commit!'
app/services/commits/create_service.rb:19:in `execute'
app/controllers/concerns/creates_commit.rb:23:in `create_commit'
app/controllers/projects/blob_controller.rb:31:in `create'
actionpack (4.2.10) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.2.10) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.10) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.10) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
[2] pry(main)> u = User.first
User Load (1.0ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1
↳ (pry):2
=> #<User id:1 @root>
[3] pry(main)> u.commit_email
=> nil
In looking at the code, I see:
def commit_email
return unless has_attribute?(:commit_email)
# The commit email is the same as the primary email if undefined
super.presence || self.email
end
It turns out I was missing the migration.
@nick.thomas Should this be:
return self.email unless @nichas_attribute?(:commit_email)