Skip to content

Commit 8671742

Browse files
committed
Merge pull request #63 from kevinjalbert/fix-rugged-and-other-updates
Fix Rugged and other updates
2 parents d457fec + 1e83f47 commit 8671742

22 files changed

+468
-374
lines changed

.rubocop.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ AllCops:
33
- '**/Rakefile'
44
- '**/*.rake'
55

6+
AbcSize:
7+
Enabled: false
8+
69
ClassLength:
710
Enabled: false
811

@@ -18,6 +21,9 @@ EmptyLineBetweenDefs:
1821
Encoding:
1922
EnforcedStyle: when_needed
2023

24+
FileName:
25+
Enabled: false
26+
2127
LineLength:
2228
Enabled: false
2329

.ruby-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

.travis.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,25 @@ rvm:
44
- 1.9.3
55
- 2.0.0
66
- 2.1.0
7+
- 2.2.0
8+
9+
# Tests are ran against the repos early history
10+
git:
11+
depth: 10000
712

813
bundler_args: --without darwin debug
914

1015
notifications:
1116
email: false
1217

1318
before_script:
14-
# Grit's Commit.find_all(...) requires the master branch to be present
15-
- git remote add master git://github.com/kevinjalbert/git_statistics.git
16-
- git fetch master
19+
# Tests requires the master branch to be present
20+
- git fetch origin
1721
- git checkout master
1822
- git checkout -
1923

20-
# Tests are ran against the repos early history
21-
- git pull origin -q --depth=1000000
24+
script: bundle exec rspec
2225

23-
script: bundle exec rspec spec
26+
before_install:
27+
- gem update --system
28+
- gem install bundler

Gemfile

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
source 'https://rubygems.org'
22

3+
gemspec
4+
35
group :test do
4-
gem 'rspec'
5-
gem "simplecov"
6-
gem 'coveralls', require: false
6+
gem 'rspec', '~> 3.4'
7+
gem 'simplecov', '~> 0.11'
8+
gem 'coveralls', '~> 0.8', require: false
79
end
810

911
group :development do
10-
gem "guard-rspec"
11-
gem "rubocop"
12-
gem "pry-debugger"
13-
gem "pry-stack_explorer"
12+
gem 'guard-rspec', '~> 4.6'
13+
gem 'rubocop', '~> 0.35'
14+
gem 'pry-stack_explorer', '~> 0.4'
1415
end
1516

1617
group :darwin do
17-
gem "rb-fsevent"
18-
gem "terminal-notifier-guard"
18+
gem 'rb-fsevent', '~> 0.9'
19+
gem 'terminal-notifier-guard', '~> 1.6'
1920
end
20-
21-
gem 'rake'
22-
gem 'json'
23-
gem 'rugged'
24-
gem 'language_sniffer'

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Git Statistics
22

3-
[![Gitter Chat](http://img.shields.io/badge/chat-gitter-brightgreen.svg)](https://gitter.im/kevinjalbert/git_statistics)
43
[![Gem Version](https://badge.fury.io/rb/git_statistics.svg)](http://badge.fury.io/rb/git_statistics)
54
[![Build Status](https://travis-ci.org/kevinjalbert/git_statistics.svg?branch=master)](http://travis-ci.org/kevinjalbert/git_statistics)
65
[![Coverage Status](https://img.shields.io/coveralls/kevinjalbert/git_statistics.svg)](https://coveralls.io/r/kevinjalbert/git_statistics)

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require 'rubocop/rake_task'
77

88
CLOBBER.include('coverage')
99

10-
Rubocop::RakeTask.new
10+
RuboCop::RakeTask.new
1111

1212
desc 'Run all specs'
1313
RSpec::Core::RakeTask.new do |t|

git_statistics.gemspec

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
# -*- encoding: utf-8 -*-
2-
$:.unshift File.expand_path("../lib", __FILE__)
2+
$:.unshift File.expand_path('../lib', __FILE__)
33
require 'git_statistics/version'
44

55
Gem::Specification.new do |gem|
66
gem.homepage = 'https://github.com/kevinjalbert/git_statistics'
7-
gem.authors = ["Kevin Jalbert"]
8-
gem.email = ["kevin.j.jalbert@gmail.com"]
7+
gem.authors = ['Kevin Jalbert']
8+
gem.email = ['kevin.j.jalbert@gmail.com']
99
gem.name = 'git_statistics'
1010
gem.version = GitStatistics::VERSION
11-
gem.summary = "Gem that provides the ability to gather detailed git statistics"
12-
gem.description = "git_statistics is a gem that provides detailed git statistics"
13-
gem.require_paths = ["lib"]
11+
gem.summary = 'Gem that provides the ability to gather detailed git statistics'
12+
gem.description = 'git_statistics is a gem that provides detailed git statistics'
13+
gem.require_paths = ['lib']
1414
gem.files = Dir['lib/**/*']
1515
gem.test_files = Dir['spec/**/*_spec.rb']
16-
gem.executables = %w[ git_statistics git-statistics ]
16+
gem.executables = %w(git_statistics git-statistics)
1717
gem.required_ruby_version = '>= 1.9.3'
18+
19+
gem.add_development_dependency 'bundler', '>= 1.6.0'
20+
gem.add_development_dependency 'rake', '~> 10.0'
21+
22+
gem.add_runtime_dependency 'json', '~> 1.8.3'
23+
gem.add_runtime_dependency 'rugged', '~> 0.23.3'
24+
gem.add_runtime_dependency 'language_sniffer', '~> 1.0.2'
1825
end

lib/git_statistics.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ class CLI
77
DEFAULT_BRANCH = 'master'
88

99
def initialize(dir)
10-
repository_location = dir.nil? ? Rugged::Repository.discover(Dir.pwd) : Rugged::Repository.discover(dir)
11-
@repository = Rugged::Repository.new(repository_location)
10+
@repository = dir.nil? ? Rugged::Repository.discover(Dir.pwd) : Rugged::Repository.discover(dir)
1211
@collected = false
1312
@collector = nil
1413
@options = OpenStruct.new(

lib/git_statistics/collector.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ def initialize(repo, limit, fresh, pretty)
99
end
1010

1111
def collect(options = {})
12-
branch = options[:branch] ? options[:branch] : CLI::DEFAULT_BRANCH
13-
branch_head = Rugged::Branch.lookup(repo, branch).tip
12+
branch_name = options[:branch] ? options[:branch] : CLI::DEFAULT_BRANCH
1413

1514
walker = Rugged::Walker.new(repo)
16-
walker.push(branch_head)
15+
walker.push(repo.branches[branch_name].target)
1716

1817
walker.each_with_index do |commit, count|
1918
next unless valid_commit?(commit, options)
@@ -51,7 +50,7 @@ def acquire_commit_meta(commit_summary)
5150
data[:added_files] = commit_summary.added_files
5251
data[:deleted_files] = commit_summary.deleted_files
5352
data[:modified_files] = commit_summary.modified_files
54-
data[:files] = commit_summary.file_stats.map { |file| file.to_json }
53+
data[:files] = commit_summary.file_stats.map(&:to_json)
5554

5655
data
5756
end

lib/git_statistics/commit_summary.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ def merge?
1616

1717
# How many files were removed in this commit
1818
def deleted_files
19-
file_stats.select { |file| file.status == :deleted }.count
19+
file_stats.count { |file| file.status == :deleted }
2020
end
2121

2222
# How many files were added in this commit
2323
def added_files
24-
file_stats.select { |file| file.status == :added }.count
24+
file_stats.count { |file| file.status == :added }
2525
end
2626

2727
# How many files were modified (not added/deleted) in this commit
2828
def modified_files
29-
file_stats.select { |file| file.status == :modified }.count
29+
file_stats.count { |file| file.status == :modified }
3030
end
3131

3232
# How many total additions in this commit?

0 commit comments

Comments
 (0)