diff --git a/Gemfile b/Gemfile index c49c3d79cc8c15ff6adc152e8de67e10e9e9d8d0..9686bf9610f98c7c4b03e08e7e0f0c59eedc641c 100644 --- a/Gemfile +++ b/Gemfile @@ -31,7 +31,7 @@ gem 'omniauth-shibboleth' # Extracting information from a git repository # Provide access to Gitlab::Git library -gem "gitlab_git", '7.0.0.rc2' +gem "gitlab_git", '7.0.0.rc3' # Ruby/Rack Git Smart-HTTP Server Handler gem 'gitlab-grack', '~> 2.0.0.pre', require: 'grack' diff --git a/Gemfile.lock b/Gemfile.lock index 26b406f7fa10f9208cbc54e403ae423654aa6c1d..d59543e9ab79ba6571176f9739f157eb31205fec 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -179,7 +179,7 @@ GEM mime-types (~> 1.19) gitlab_emoji (0.0.1.1) emoji (~> 1.0.1) - gitlab_git (7.0.0.rc2) + gitlab_git (7.0.0.rc3) activesupport (~> 4.0) charlock_holmes (~> 0.6) gitlab-linguist (~> 3.0) @@ -618,7 +618,7 @@ DEPENDENCIES gitlab-grack (~> 2.0.0.pre) gitlab-linguist (~> 3.0.0) gitlab_emoji (~> 0.0.1.1) - gitlab_git (= 7.0.0.rc2) + gitlab_git (= 7.0.0.rc3) gitlab_meta (= 7.0) gitlab_omniauth-ldap (= 1.1.0) gollum-lib (~> 3.0.0) diff --git a/app/assets/javascripts/stat_graph_contributors.js.coffee b/app/assets/javascripts/stat_graph_contributors.js.coffee index 168b733704102bd21a30889433f87b7f5781d610..ab785a5454328452bf89ebad191b5e12036cd1d5 100644 --- a/app/assets/javascripts/stat_graph_contributors.js.coffee +++ b/app/assets/javascripts/stat_graph_contributors.js.coffee @@ -24,22 +24,7 @@ class window.ContributorsStatGraph class: 'graph-author-commits-count' }) commits.text(author.commits + " commits") - - additions = $('', { - class: 'graph-additions' - }) - additions.text(author.additions + " ++") - - deletions = $('', { - class: 'graph-deletions' - }) - deletions.text(author.deletions + " --") - $('').append(commits) - .append(" / ") - .append(additions) - .append(" / ") - .append(deletions) create_author_header: (author) -> list_item = $('
  • ', { diff --git a/app/assets/javascripts/stat_graph_contributors_util.js.coffee b/app/assets/javascripts/stat_graph_contributors_util.js.coffee index 364cab183777e9e107ddd831d7f0f6dda747c075..1670f5c7bc1916b6759b239ebc7380e6357662a3 100644 --- a/app/assets/javascripts/stat_graph_contributors_util.js.coffee +++ b/app/assets/javascripts/stat_graph_contributors_util.js.coffee @@ -90,4 +90,4 @@ window.ContributorsStatGraphUtil = true else false - + diff --git a/app/controllers/projects/graphs_controller.rb b/app/controllers/projects/graphs_controller.rb index 252d47d939e291b9d2b324fdf5d322be68bcfd11..92bb5607f81ab02097b2a983fac7c3954933d63d 100644 --- a/app/controllers/projects/graphs_controller.rb +++ b/app/controllers/projects/graphs_controller.rb @@ -7,7 +7,7 @@ class Projects::GraphsController < Projects::ApplicationController def show respond_to do |format| format.html - format.js do + format.json do fetch_graph end end @@ -16,10 +16,17 @@ class Projects::GraphsController < Projects::ApplicationController private def fetch_graph - @log = @project.repository.graph_log.to_json - @success = true - rescue => ex + @commits = @project.repository.commits(nil, nil, 6000, 0, true) @log = [] - @success = false + + @commits.each do |commit| + @log << { + author_name: commit.author_name.force_encoding('UTF-8'), + author_email: commit.author_email.force_encoding('UTF-8'), + date: commit.committed_date.strftime("%Y-%m-%d") + } + end + + render json: @log.to_json end end diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb index c030320d037c85ad21f6a535d6d1c560b42d33f0..4e0f190ed1cdb345448425f518cf59b2198c6ff8 100644 --- a/app/controllers/projects/repositories_controller.rb +++ b/app/controllers/projects/repositories_controller.rb @@ -4,11 +4,6 @@ class Projects::RepositoriesController < Projects::ApplicationController before_filter :authorize_code_access! before_filter :require_non_empty_project - def stats - @stats = Gitlab::Git::Stats.new(@repository.raw_repository, @repository.root_ref) - @graph = @stats.graph - end - def archive unless can?(current_user, :download_code, @project) render_404 and return diff --git a/app/models/repository.rb b/app/models/repository.rb index a2bdfe874697d47dd294cd239e92a840ce56a9fb..b7ca6e0919f68fdcd68f1d647ef0322efc11f9ce 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -32,7 +32,7 @@ class Repository commit end - def commits(ref, path = nil, limit = nil, offset = nil) + def commits(ref, path = nil, limit = nil, offset = nil, skip_merges = false) commits = Gitlab::Git::Commit.where( repo: raw_repository, ref: ref, diff --git a/app/views/projects/commits/_head.html.haml b/app/views/projects/commits/_head.html.haml index 2dcd84af010a4469affac377b5c84002c0cd84bc..0c9d906481bbb0b28ca939019067e5e1bea09c09 100644 --- a/app/views/projects/commits/_head.html.haml +++ b/app/views/projects/commits/_head.html.haml @@ -13,7 +13,3 @@ = link_to project_tags_path(@project) do Tags %span.badge.js-totaltags-count= @repository.tags.length - - = nav_link(controller: :repositories, action: :stats) do - = link_to stats_project_repository_path(@project) do - Stats diff --git a/app/views/projects/graphs/show.html.haml b/app/views/projects/graphs/show.html.haml index 8e4548f26d0b3589e365d87f0d13b4f8d26da3c1..c2878e13e7cd7a97eed6fa44c7dc2413ab13a37d 100644 --- a/app/views/projects/graphs/show.html.haml +++ b/app/views/projects/graphs/show.html.haml @@ -3,15 +3,10 @@ %h3.page-title %i.icon-spinner.icon-spin Building repository graph. - %p Please wait a moment, this page will automatically refresh when ready. + %p.slead Please wait a moment, this page will automatically refresh when ready. -.stat-graph +.stat-graph.hide .header.clearfix - .pull-right - %select - %option{:value => "commits"} Commits - %option{:value => "additions"} Additions - %option{:value => "deletions"} Deletions %h3#date_header.page-title %p.light Commits to #{@project.default_branch}, excluding merge commits. Limited by 6,000 commits @@ -21,15 +16,21 @@ #contributors.clearfix %ol.contributors-list.clearfix -:javascript - $(".stat-graph").hide(); - $.ajax({ + +:coffeescript + $.ajax type: "GET", url: location.href, - complete: function() { + success: (data) -> + graph = new ContributorsStatGraph() + graph.init(data) + + $("#brush_change").change -> + graph.change_date_header() + graph.redraw_authors() + $(".stat-graph").fadeIn(); $(".loading-graph").hide(); - }, - dataType: "script" - }); + dataType: "json" + diff --git a/app/views/projects/graphs/show.js.haml b/app/views/projects/graphs/show.js.haml deleted file mode 100644 index dcf6cacdcebf520b019b7a6f6b3cb4d3c79440c2..0000000000000000000000000000000000000000 --- a/app/views/projects/graphs/show.js.haml +++ /dev/null @@ -1,19 +0,0 @@ -- if @success - :plain - controller = new ContributorsStatGraph - controller.init(#{@log}) - - $("select").change( function () { - var field = $(this).val() - controller.set_current_field(field) - controller.redraw_master() - controller.redraw_authors() - }) - - $("#brush_change").change( function () { - controller.change_date_header() - controller.redraw_authors() - }) -- else - :plain - $('.stat-graph').replaceWith('
    Failed to load graph
    ') diff --git a/app/views/projects/repositories/stats.html.haml b/app/views/projects/repositories/stats.html.haml deleted file mode 100644 index 70db27d644457de27573e1420b3f302b14621e23..0000000000000000000000000000000000000000 --- a/app/views/projects/repositories/stats.html.haml +++ /dev/null @@ -1,33 +0,0 @@ -= render "projects/commits/head" -.row - .col-md-6 - %div#activity-chart.chart - %hr - %p - %b Total commits: - %span= @repository.commit_count - %p - %b Total files in #{@repository.root_ref}: - %span= @stats.files_count - %p - %b Authors: - %span= @stats.authors_count - - - .col-md-6 - %h4 Top 50 Committers: - %ol.styled - - @stats.authors[0...50].each do |author| - %li - = image_tag avatar_icon(author.email, 16), class: 'avatar s16', alt: '' - = author.name - %small.light= author.email - .pull-right - = author.commits - - -:javascript - var labels = [#{@graph.labels.to_json}]; - var commits = [#{@graph.commits.join(', ')}]; - var title = "Commit activity for last #{@graph.weeks} weeks"; - Chart.init(labels, commits, title); diff --git a/config/routes.rb b/config/routes.rb index 39ab9f4265ace0cab725dd6395532099f5edc1b1..ba3cb8bd4cf439a22361593ee33b178e53427496 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -230,7 +230,6 @@ Gitlab::Application.routes.draw do resource :repository, only: [:show] do member do - get "stats" get "archive", constraints: { format: Gitlab::Regex.archive_formats_regex } end end diff --git a/features/project/commits/commits.feature b/features/project/commits/commits.feature index 7c6db3c465af1b375a15329ad45697260a74363e..8a213067548552fa1b1cc60acf321f9fcbbefa82 100644 --- a/features/project/commits/commits.feature +++ b/features/project/commits/commits.feature @@ -30,9 +30,10 @@ Feature: Project Browse commits Given I visit my project's commits page for a specific path Then I see breadcrumb links - Scenario: I browse commits stats - Given I visit my project's commits stats page - Then I see commits stats + # TODO: Implement feature in graphs + #Scenario: I browse commits stats + #Given I visit my project's commits stats page + #Then I see commits stats Scenario: I browse big commit Given I visit big commit page