Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

Commit f5da98d

Browse files
author
Lennon Day-Reynolds
committed
Merge branch 'master' of git://github.com/robinluckey/ohloh_scm
2 parents 5a2b683 + 4502c5b commit f5da98d

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/scm/adapters/bzr/commits.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,18 @@ def verbose_commit(token)
4949
def each_commit(since=0)
5050
open_log_file(since) do |io|
5151
Scm::Parsers::BzrParser.parse(io) do |commit|
52-
yield commit if block_given? && commit.token != since
52+
yield remove_directories(commit) if block_given? && commit.token != since
5353
end
5454
end
5555
end
5656

57+
# Ohloh tracks only files, not directories. This function removes directories
58+
# from the commit diffs.
59+
def remove_directories(commit)
60+
commit.diffs.delete_if { |d| d.path[-1..-1] == '/' }
61+
commit
62+
end
63+
5764
# Not used by Ohloh proper, but handy for debugging and testing
5865
def log(since=nil)
5966
run "#{rev_list_command(since)} -v"

test/unit/bzr_commits_test.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,23 @@ def test_each_commit
6363
end
6464
end
6565

66+
# This bzr repository contains the following tree structure
67+
# /foo/
68+
# /foo/helloworld.c
69+
# /bar/
70+
# Ohloh doesn't care about directories, so only /foo/helloworld.c should be reported.
71+
def test_each_commit_excludes_directories
72+
with_bzr_repository('bzr_with_subdirectories') do |bzr|
73+
commits = []
74+
bzr.each_commit do |c|
75+
commits << c
76+
end
77+
assert_equal 1, commits.size
78+
assert_equal 1, commits.first.diffs.size
79+
assert_equal 'foo/helloworld.c', commits.first.diffs.first.path
80+
end
81+
end
82+
6683
protected
6784

6885
def revision_ids

0 commit comments

Comments
 (0)