Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Issues
  • #637

Closed
Open
Created Apr 02, 2012 by Administrator@rootOwner

prev_commit_id generates error after committing data merged from `git read-tree`

Created by: koenpunt

After merging an external repository into a subdirectory of the repository using something like git read-tree --prefix=my_external_repo/ -u my-external-repo/master and pushing it to the remote, gitlab displays an 500 error on the dashboard page and the concerning project page. I managed to trace it to the following error:

Started GET "/" for xx.xxx.xxx.xx at 2012-04-02 01:16:54 +0200
Processing by DashboardController#index as HTML
  Rendered dashboard/_projects_feed.html.haml (16.2ms)
  Rendered events/_event_push.html.haml (2222.4ms)
  Rendered events/_event.html.haml (2245.3ms)
  Rendered dashboard/index.html.haml within layouts/application (2546.9ms)
Completed 500 Internal Server Error in 3751ms

ActionView::Template::Error (undefined method `id' for nil:NilClass):
    29:     = time_ago_in_words(event.created_at)
    30:     ago.
    31:   - if event.commits.count > 1
    32:     = link_to compare_project_commits_path(event.project, :from => event.commits.first.prev_commit_id, :to => event.commits.last.id) do
    33:       %strong #{event.commits.first.commit.id[0..7]}...#{event.commits.last.id[0..7]}
    34:   - project = event.project
    35:   %ul.unstyled.event_commits
  app/models/commit.rb:121:in `prev_commit_id'
  app/views/events/_event_push.html.haml:32:in `_app_views_events__event_push_html_haml___1118036226559512333_42737820'
  app/views/events/_event.html.haml:12:in `_app_views_events__event_html_haml___3039848936176638395_43631940'
  app/views/dashboard/index.html.haml:42:in `_app_views_dashboard_index_html_haml__949257223860260556_50017300'

So apparently the commit doesn't have parents so parents.first in prev_commit returns a nil

I fixed it for now by changing

def prev_commit_id
    prev_commit.id
end

to

def prev_commit_id
    prev_commit.id if prev_commit
end

in app/models/commit.rb

Assignee
Assign to
Time tracking