diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-01-05 18:44:22 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-01-05 18:44:22 +0300 |
commit | 07c39c9976bcceca94b11525917cd27db8088b2f (patch) | |
tree | 332c4bb637056e04cb54edfa75396e2a347b098b /app/views/projects/branches | |
parent | 7c3c901ada6fc4a6d2d3ce7a2cf8188cf6615008 (diff) | |
parent | 2e8ec7e7204b2876218db34439584204b1062265 (diff) |
Merge branch 'brunsa2/gitlab-ce-diverging-branch-graphs' into 'master'
Add graphs of commits ahead/behind default branch (by @brunsa2)
Replaces https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/1716
See merge request !2301
Diffstat (limited to 'app/views/projects/branches')
-rw-r--r-- | app/views/projects/branches/_branch.html.haml | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/views/projects/branches/_branch.html.haml b/app/views/projects/branches/_branch.html.haml index 5081bae6801..a234536723e 100644 --- a/app/views/projects/branches/_branch.html.haml +++ b/app/views/projects/branches/_branch.html.haml @@ -1,4 +1,8 @@ - commit = @repository.commit(branch.target) +- bar_graph_width_factor = @max_commits > 0 ? 100.0/@max_commits : 0 +- diverging_commit_counts = @repository.diverging_commit_counts(branch) +- number_commits_behind = diverging_commit_counts[:behind] +- number_commits_ahead = diverging_commit_counts[:ahead] %li(class="js-branch-#{branch.name}") %div = link_to namespace_project_tree_path(@project.namespace, @project, branch.name) do @@ -29,6 +33,17 @@ = link_to namespace_project_branch_path(@project.namespace, @project, branch.name), class: 'btn btn-grouped btn-xs btn-remove remove-row has_tooltip', title: "Delete branch", method: :delete, data: { confirm: "Deleting the '#{branch.name}' branch cannot be undone. Are you sure?", container: 'body' }, remote: true do = icon("trash-o") + - if branch.name != @repository.root_ref + .divergence-graph{ title: "#{number_commits_ahead} commits ahead, #{number_commits_behind} commits behind #{@repository.root_ref}" } + .graph-side + .bar.bar-behind{ style: "width: #{number_commits_behind * bar_graph_width_factor}%" } + %span.count.count-behind= number_commits_behind + .graph-separator + .graph-side + .bar.bar-ahead{ style: "width: #{number_commits_ahead * bar_graph_width_factor}%" } + %span.count.count-ahead= number_commits_ahead + + - if commit = render 'projects/branches/commit', commit: commit, project: @project - else |