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

Commit

Permalink
Merge branch 'master' of git://github.com/robinluckey/ohloh_scm
Browse files Browse the repository at this point in the history
  • Loading branch information
Lennon Day-Reynolds committed Feb 6, 2009
2 parents 5a2b683 + 4502c5b commit f5da98d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/scm/adapters/bzr/commits.rb
Expand Up @@ -49,11 +49,18 @@ def verbose_commit(token)
def each_commit(since=0)
open_log_file(since) do |io|
Scm::Parsers::BzrParser.parse(io) do |commit|
yield commit if block_given? && commit.token != since
yield remove_directories(commit) if block_given? && commit.token != since
end
end
end

# Ohloh tracks only files, not directories. This function removes directories
# from the commit diffs.
def remove_directories(commit)
commit.diffs.delete_if { |d| d.path[-1..-1] == '/' }
commit
end

# Not used by Ohloh proper, but handy for debugging and testing
def log(since=nil)
run "#{rev_list_command(since)} -v"
Expand Down
17 changes: 17 additions & 0 deletions test/unit/bzr_commits_test.rb
Expand Up @@ -63,6 +63,23 @@ def test_each_commit
end
end

# This bzr repository contains the following tree structure
# /foo/
# /foo/helloworld.c
# /bar/
# Ohloh doesn't care about directories, so only /foo/helloworld.c should be reported.
def test_each_commit_excludes_directories
with_bzr_repository('bzr_with_subdirectories') do |bzr|
commits = []
bzr.each_commit do |c|
commits << c
end
assert_equal 1, commits.size
assert_equal 1, commits.first.diffs.size
assert_equal 'foo/helloworld.c', commits.first.diffs.first.path
end
end

protected

def revision_ids
Expand Down

0 comments on commit f5da98d

Please sign in to comment.