gitlab_git 7.0.0.rc2 → 7.0.0.rc3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/gitlab_git.rb +0 -3
- data/lib/gitlab_git/repository.rb +8 -1
- metadata +1 -4
- data/lib/gitlab_git/git_stats.rb +0 -75
- data/lib/gitlab_git/log_parser.rb +0 -31
- data/lib/gitlab_git/stats.rb +0 -80
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: ff461d9ee572c8e82ed303b222d4719bce93dcc5
         | 
| 4 | 
            +
              data.tar.gz: 16c2b9ada62bb3452b237ef921bfc004ac2aaaa6
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: a2cf2dceb0d689ee5489724ffb920cc61605de1728ba00fb9168e136a9f262c8d75cdcedc19a4605e420b3b2ba0cce8bd643d46424a05ad77926fcd3e63bdcdd
         | 
| 7 | 
            +
              data.tar.gz: c55192100961a6311fc981b240fec387bc87faeefb1ec637f608c0e9008e67bbe32055f694b2fe325a23f2e361637e1fe3d7d8482008738b9c17c2c94cb69ed1
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            7.0.0. | 
| 1 | 
            +
            7.0.0.rc3
         | 
    
        data/lib/gitlab_git.rb
    CHANGED
    
    | @@ -18,11 +18,8 @@ require_relative "gitlab_git/commit_stats" | |
| 18 18 | 
             
            require_relative "gitlab_git/compare"
         | 
| 19 19 | 
             
            require_relative "gitlab_git/diff"
         | 
| 20 20 | 
             
            require_relative "gitlab_git/repository"
         | 
| 21 | 
            -
            require_relative "gitlab_git/stats"
         | 
| 22 21 | 
             
            require_relative "gitlab_git/tree"
         | 
| 23 22 | 
             
            require_relative "gitlab_git/blob_snippet"
         | 
| 24 | 
            -
            require_relative "gitlab_git/git_stats"
         | 
| 25 | 
            -
            require_relative "gitlab_git/log_parser"
         | 
| 26 23 | 
             
            require_relative "gitlab_git/ref"
         | 
| 27 24 | 
             
            require_relative "gitlab_git/branch"
         | 
| 28 25 | 
             
            require_relative "gitlab_git/tag"
         | 
| @@ -198,7 +198,8 @@ module Gitlab | |
| 198 198 | 
             
                      offset: 0,
         | 
| 199 199 | 
             
                      path: nil,
         | 
| 200 200 | 
             
                      ref: root_ref,
         | 
| 201 | 
            -
                      follow: false
         | 
| 201 | 
            +
                      follow: false,
         | 
| 202 | 
            +
                      skip_merges: false
         | 
| 202 203 | 
             
                    }
         | 
| 203 204 |  | 
| 204 205 | 
             
                    options = default_options.merge(options)
         | 
| @@ -737,11 +738,17 @@ module Gitlab | |
| 737 738 |  | 
| 738 739 | 
             
                    limit = options[:limit].to_i
         | 
| 739 740 | 
             
                    offset = options[:offset].to_i
         | 
| 741 | 
            +
                    skip_merges = options[:skip_merges]
         | 
| 740 742 |  | 
| 741 743 | 
             
                    walker.sorting(Rugged::SORT_DATE)
         | 
| 742 744 | 
             
                    walker.each do |c|
         | 
| 743 745 | 
             
                      break if limit > 0 && commits.length >= limit
         | 
| 744 746 |  | 
| 747 | 
            +
                      if skip_merges
         | 
| 748 | 
            +
                        # Skip merge commits
         | 
| 749 | 
            +
                        next if c.parents.length > 1
         | 
| 750 | 
            +
                      end
         | 
| 751 | 
            +
             | 
| 745 752 | 
             
                      if !current_path ||
         | 
| 746 753 | 
             
                        commit_touches_path?(c, current_path, options[:follow])
         | 
| 747 754 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: gitlab_git
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 7.0.0. | 
| 4 | 
            +
              version: 7.0.0.rc3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Dmitriy Zaporozhets
         | 
| @@ -97,12 +97,9 @@ files: | |
| 97 97 | 
             
            - lib/gitlab_git/compare.rb
         | 
| 98 98 | 
             
            - lib/gitlab_git/diff.rb
         | 
| 99 99 | 
             
            - lib/gitlab_git/encoding_helper.rb
         | 
| 100 | 
            -
            - lib/gitlab_git/git_stats.rb
         | 
| 101 | 
            -
            - lib/gitlab_git/log_parser.rb
         | 
| 102 100 | 
             
            - lib/gitlab_git/popen.rb
         | 
| 103 101 | 
             
            - lib/gitlab_git/ref.rb
         | 
| 104 102 | 
             
            - lib/gitlab_git/repository.rb
         | 
| 105 | 
            -
            - lib/gitlab_git/stats.rb
         | 
| 106 103 | 
             
            - lib/gitlab_git/tag.rb
         | 
| 107 104 | 
             
            - lib/gitlab_git/tree.rb
         | 
| 108 105 | 
             
            homepage: http://rubygems.org/gems/gitlab_git
         | 
    
        data/lib/gitlab_git/git_stats.rb
    DELETED
    
    | @@ -1,75 +0,0 @@ | |
| 1 | 
            -
            require_relative 'log_parser'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            module Gitlab
         | 
| 4 | 
            -
              module Git
         | 
| 5 | 
            -
                class GitStats
         | 
| 6 | 
            -
                  attr_accessor :repo, :ref, :timeout
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                  def initialize(repo, ref, timeout = 30)
         | 
| 9 | 
            -
                    @repo, @ref, @timeout = repo, ref, timeout
         | 
| 10 | 
            -
                  end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                  # Returns a string of log information; equivalent to running 'git log`
         | 
| 13 | 
            -
                  # with these options:
         | 
| 14 | 
            -
                  #
         | 
| 15 | 
            -
                  # -6000
         | 
| 16 | 
            -
                  # --format=%aN%x0a%aE%x0a%cd
         | 
| 17 | 
            -
                  # --date=short
         | 
| 18 | 
            -
                  # --shortstat
         | 
| 19 | 
            -
                  # --no-merges
         | 
| 20 | 
            -
                  # --diff-filter=ACDM
         | 
| 21 | 
            -
                  def log
         | 
| 22 | 
            -
                    commit_strings = []
         | 
| 23 | 
            -
                    walker = Rugged::Walker.new(repo.rugged)
         | 
| 24 | 
            -
                    walker.push(repo.lookup(ref))
         | 
| 25 | 
            -
                    walker.each(limit: 6000) do |commit|
         | 
| 26 | 
            -
                      # Skip merge commits
         | 
| 27 | 
            -
                      next if commit.parents.length > 1
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                      g_commit = Gitlab::Git::Commit.new(commit)
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                      commit_strings << [
         | 
| 32 | 
            -
                        g_commit.author_name,
         | 
| 33 | 
            -
                        g_commit.author_email,
         | 
| 34 | 
            -
                        g_commit.committed_date.strftime("%Y-%m-%d"),
         | 
| 35 | 
            -
                        "",
         | 
| 36 | 
            -
                        status_string(g_commit)
         | 
| 37 | 
            -
                      ].join("\n")
         | 
| 38 | 
            -
                    end
         | 
| 39 | 
            -
             | 
| 40 | 
            -
                    commit_strings.join("\n")
         | 
| 41 | 
            -
                  end
         | 
| 42 | 
            -
             | 
| 43 | 
            -
                  def parsed_log
         | 
| 44 | 
            -
                    LogParser.parse_log(log)
         | 
| 45 | 
            -
                  end
         | 
| 46 | 
            -
             | 
| 47 | 
            -
                  private
         | 
| 48 | 
            -
             | 
| 49 | 
            -
                  # Returns a string describing the files changed, additions and deletions
         | 
| 50 | 
            -
                  # for +commit+
         | 
| 51 | 
            -
                  def status_string(commit)
         | 
| 52 | 
            -
                    stats = commit.stats
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                    status = "#{num_files_changed(commit)} files changed"
         | 
| 55 | 
            -
                    status << ", #{stats.additions} insertions" if stats.additions > 0
         | 
| 56 | 
            -
                    status << ", #{stats.deletions} deletions" if stats.deletions > 0
         | 
| 57 | 
            -
                    status
         | 
| 58 | 
            -
                  end
         | 
| 59 | 
            -
             | 
| 60 | 
            -
                  # Returns the number of files that were either added, copied, deleted, or
         | 
| 61 | 
            -
                  # modified by +commit+
         | 
| 62 | 
            -
                  def num_files_changed(commit)
         | 
| 63 | 
            -
                    count = 0
         | 
| 64 | 
            -
             | 
| 65 | 
            -
                    diff = commit.diff_from_parent
         | 
| 66 | 
            -
                    diff.find_similar!
         | 
| 67 | 
            -
                    diff.each_delta do |d|
         | 
| 68 | 
            -
                      count += 1 if d.added? || d.copied? || d.deleted? || d.modified?
         | 
| 69 | 
            -
                    end
         | 
| 70 | 
            -
             | 
| 71 | 
            -
                    count
         | 
| 72 | 
            -
                  end
         | 
| 73 | 
            -
                end
         | 
| 74 | 
            -
              end
         | 
| 75 | 
            -
            end
         | 
| @@ -1,31 +0,0 @@ | |
| 1 | 
            -
            module Gitlab
         | 
| 2 | 
            -
              module Git
         | 
| 3 | 
            -
                class LogParser
         | 
| 4 | 
            -
                  # Parses the log file into a collection of commits
         | 
| 5 | 
            -
                  # Data model:
         | 
| 6 | 
            -
                  #   {author_name, author_email, date, additions, deletions}
         | 
| 7 | 
            -
                  def self.parse_log(log_from_git)
         | 
| 8 | 
            -
                    log = log_from_git.split("\n")
         | 
| 9 | 
            -
                    collection = []
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                    log.each_slice(5) do |slice|
         | 
| 12 | 
            -
                      entry = {}
         | 
| 13 | 
            -
                      entry[:author_name] = slice[0].force_encoding('UTF-8')
         | 
| 14 | 
            -
                      entry[:author_email] = slice[1].force_encoding('UTF-8')
         | 
| 15 | 
            -
                      entry[:date] = slice[2]
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                      if slice[4]
         | 
| 18 | 
            -
                        changes = slice[4]
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                        entry[:additions] = $1.to_i if changes =~ /(\d+) insertion/
         | 
| 21 | 
            -
                        entry[:deletions] = $1.to_i if changes =~ /(\d+) deletion/
         | 
| 22 | 
            -
                      end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
                      collection.push(entry)
         | 
| 25 | 
            -
                    end
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                    collection
         | 
| 28 | 
            -
                  end
         | 
| 29 | 
            -
                end
         | 
| 30 | 
            -
              end
         | 
| 31 | 
            -
            end
         | 
    
        data/lib/gitlab_git/stats.rb
    DELETED
    
    | @@ -1,80 +0,0 @@ | |
| 1 | 
            -
            module Gitlab
         | 
| 2 | 
            -
              module Git
         | 
| 3 | 
            -
                class Stats
         | 
| 4 | 
            -
                  attr_accessor :repo, :ref
         | 
| 5 | 
            -
             | 
| 6 | 
            -
                  def initialize repo, ref
         | 
| 7 | 
            -
                    @repo, @ref = repo, ref
         | 
| 8 | 
            -
                  end
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                  def authors
         | 
| 11 | 
            -
                    @authors ||= collect_authors
         | 
| 12 | 
            -
                  end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                  def commits_count
         | 
| 15 | 
            -
                    @commits_count ||= repo.commit_count(ref)
         | 
| 16 | 
            -
                  end
         | 
| 17 | 
            -
             | 
| 18 | 
            -
                  def files_count
         | 
| 19 | 
            -
                    index = repo.rugged.index
         | 
| 20 | 
            -
                    index.read_tree(repo.rugged.head.target.tree)
         | 
| 21 | 
            -
                    index.count
         | 
| 22 | 
            -
                  end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
                  def authors_count
         | 
| 25 | 
            -
                    authors.size
         | 
| 26 | 
            -
                  end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
                  def graph
         | 
| 29 | 
            -
                    @graph ||= build_graph
         | 
| 30 | 
            -
                  end
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                  protected
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                  def collect_authors
         | 
| 35 | 
            -
                    commits = repo.log(ref: ref, limit: 0)
         | 
| 36 | 
            -
             | 
| 37 | 
            -
                    author_stats = {}
         | 
| 38 | 
            -
                    commits.each do |commit|
         | 
| 39 | 
            -
                      if author_stats.key?(commit.author[:name])
         | 
| 40 | 
            -
                        author_stats[commit.author[:name]][:count] += 1
         | 
| 41 | 
            -
                      else
         | 
| 42 | 
            -
                        author_stats[commit.author[:name]] = {
         | 
| 43 | 
            -
                          email: commit.author[:email],
         | 
| 44 | 
            -
                          count: 1
         | 
| 45 | 
            -
                        }
         | 
| 46 | 
            -
                      end
         | 
| 47 | 
            -
                    end
         | 
| 48 | 
            -
             | 
| 49 | 
            -
                    authors = []
         | 
| 50 | 
            -
                    author_stats.each do |author_name, info|
         | 
| 51 | 
            -
                      authors << OpenStruct.new(
         | 
| 52 | 
            -
                        name: author_name,
         | 
| 53 | 
            -
                        email: info[:email],
         | 
| 54 | 
            -
                        commits: info[:count]
         | 
| 55 | 
            -
                      )
         | 
| 56 | 
            -
                    end
         | 
| 57 | 
            -
             | 
| 58 | 
            -
                    authors.sort_by(&:commits).reverse
         | 
| 59 | 
            -
                  end
         | 
| 60 | 
            -
             | 
| 61 | 
            -
                  def build_graph(n = 4)
         | 
| 62 | 
            -
                    from, to = (Date.today.prev_day(n*7)), Date.today
         | 
| 63 | 
            -
                    rev_list = repo.commits_since(from)
         | 
| 64 | 
            -
             | 
| 65 | 
            -
                    commits_dates = rev_list.values_at(* rev_list.each_index.select {|i| i.odd?})
         | 
| 66 | 
            -
                    commits_dates = commits_dates.map { |date_str| Time.parse(date_str).to_date.to_s }
         | 
| 67 | 
            -
             | 
| 68 | 
            -
                    commits_per_day = from.upto(to).map do |day|
         | 
| 69 | 
            -
                      commits_dates.count(day.to_date.to_s)
         | 
| 70 | 
            -
                    end
         | 
| 71 | 
            -
             | 
| 72 | 
            -
                    OpenStruct.new(
         | 
| 73 | 
            -
                      labels: from.upto(to).map { |day| day.strftime('%b %d') },
         | 
| 74 | 
            -
                      commits: commits_per_day,
         | 
| 75 | 
            -
                      weeks: n
         | 
| 76 | 
            -
                    )
         | 
| 77 | 
            -
                  end
         | 
| 78 | 
            -
                end
         | 
| 79 | 
            -
              end
         | 
| 80 | 
            -
            end
         |