This repository was archived by the owner on Dec 13, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -49,11 +49,18 @@ def verbose_commit(token)
49
49
def each_commit ( since = 0 )
50
50
open_log_file ( since ) do |io |
51
51
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
53
53
end
54
54
end
55
55
end
56
56
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
+
57
64
# Not used by Ohloh proper, but handy for debugging and testing
58
65
def log ( since = nil )
59
66
run "#{ rev_list_command ( since ) } -v"
Original file line number Diff line number Diff line change @@ -63,6 +63,23 @@ def test_each_commit
63
63
end
64
64
end
65
65
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
+
66
83
protected
67
84
68
85
def revision_ids
You can’t perform that action at this time.
0 commit comments