Class: Diggit::DevelopersActivity::Analyses::CommitsFilesAnalysis

Inherits:
ActivityAnalysis
  • Object
show all
Defined in:
lib/diggit/developers_activity/analyses/commits_files_analysis.rb

Instance Method Summary collapse

Methods inherited from ActivityAnalysis

#load_options

Methods included from Diggit::DevelopersActivity::ActivityExtractor

#extract_developers_activity

Instance Method Details

#cleanObject



41
42
43
# File 'lib/diggit/developers_activity/analyses/commits_files_analysis.rb', line 41

def clean
	db.client[COL].find({ project: @source.url }).delete_many
end

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/diggit/developers_activity/analyses/commits_files_analysis.rb', line 11

def run
	super
	r_0 = repo.lookup(src_opt[@source]["cloc-commit-id"])
	t_0 = r_0.author[:time]

	walker = Rugged::Walker.new(repo)
	walker.sorting(Rugged::SORT_DATE)
	walker.push(r_0)

	t_stop = t_0 - 12 * MONTH_SECONDS
	commits_files = []
	Modules.files_as_modules
	walker.each do |commit|
		next unless commit.parents.size == 1
		Renames.extract_commit_renames(commit, true)
		commit.parents.each do |parent|
			diff = parent.diff(commit, DIFF_OPTIONS)
			diff.find_similar!(DIFF_RENAME_OPTIONS)
			diff.each do |patch|
				maudule = Modules.get_patch_module(patch)
				next if maudule.nil?

				commits_files << { file: maudule, commit: commit.oid.to_s, project: @source.url }
			end
		end
		#break if commit.author[:time] < t_stop
	end
	db.insert(COL, commits_files)
end