diggit-developers_activity 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1edbd6db19ea1f6e92927be44f6fc51100f0a5a3
4
+ data.tar.gz: 080b18b468e0f011fd09631bd19160585a98db7e
5
+ SHA512:
6
+ metadata.gz: bb5086afe6dc38508ed69f5471c826254f0390e3661febc76c4bdbb8b16508e33a2e396481130a1699b22001af4c7204d19b7780ec27ba447cf2fcb92d9ae7fd
7
+ data.tar.gz: 82d212f17b36e2009d54ec2f1e9c9726855e16c4e8d2be8cfc8c384f8095f99bf57b3dabf20b866c70050698ff7f20a33ce49b6d656d35326bcbd6b3064fa1d5
data/.gitignore ADDED
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in diggit-developers_activity.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Diggit::DevelopersActivity
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'diggit-developers_activity'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install diggit-developers_activity
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/diggit-developers_activity/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ require "diggit/developers_activity/workspace_init"
5
+
6
+ Diggit::DevelopersActivity::WorkspaceInit.init
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'diggit/developers_activity/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "diggit-developers_activity"
8
+ spec.version = Diggit::DevelopersActivity::VERSION
9
+ spec.authors = ["Matthieu Foucault"]
10
+ spec.email = ["foucault.matthieu@gmail.com"]
11
+ spec.summary = "Analyses and dataset for the diggit tool."
12
+ spec.description = "This gem contains a set of analyses extracting developers activity from git repositories,
13
+ using different granularities of time periods. It also includes a dataset of git repositories for which we extacted
14
+ the identity of bug-fixing commits for a given release, as well as author identity merge information."
15
+ spec.homepage = ""
16
+ spec.license = "LGPL"
17
+
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+
26
+ spec.add_runtime_dependency "diggit", "~> 1.0"
27
+ end
@@ -0,0 +1,12 @@
1
+ require "diggit/developers_activity/version"
2
+ require "diggit/developers_activity/activity_extractor"
3
+ require "diggit/developers_activity/module_metrics_extractor"
4
+ require "diggit/developers_activity/analyses"
5
+ require "diggit/developers_activity/workspace_init"
6
+
7
+ module Diggit
8
+ module DevelopersActivity
9
+ DIFF_OPTIONS = { ignore_whitespace: true, ignore_filemode: true }
10
+ DIFF_RENAME_OPTIONS = { renames: true, ignore_whitespace: true }
11
+ end
12
+ end
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'diggit/developers_activity/activity_extractor/renames'
4
+ require 'diggit/developers_activity/activity_extractor/modules'
5
+ require 'diggit/developers_activity/activity_extractor/authors'
6
+ require 'diggit/developers_activity'
7
+
8
+ module Diggit
9
+ module DevelopersActivity
10
+ # Set of functions extracting developers activity for a given set of commits
11
+ module ActivityExtractor
12
+ extend self
13
+
14
+ def extract_developers_activity(source, commits, commits_group_id = nil)
15
+ return [] if commits.empty?
16
+ contributions = Hash.new { |hash, key| hash[key] = { touches: 0, churn: 0 } }
17
+ num_commits = 0
18
+
19
+ commits.each do |commit|
20
+ num_commits += 1
21
+
22
+ author = Authors.get_author(commit)
23
+
24
+ commit.parents.each do |parent|
25
+ diff = parent.diff(commit, DIFF_OPTIONS)
26
+ diff.find_similar!(DIFF_RENAME_OPTIONS)
27
+ diff.each do |patch|
28
+ maudule = Modules.get_patch_module(patch)
29
+ next if maudule.nil?
30
+
31
+ key = { author: author, 'module' => maudule }
32
+ contributions[key] = { touches: contributions[key][:touches] + 1,
33
+ churn: contributions[key][:churn] + patch.stat[0] + patch.stat[1] }
34
+ end
35
+ end
36
+ end
37
+
38
+ puts "num commits #{num_commits}"
39
+
40
+ fist_commit_date = commits[0].author[:time]
41
+
42
+ # compute metrics and write to result
43
+ developer_metrics = []
44
+ contributions.each do |key, value|
45
+ developer_metrics << { project: source, developer: key[:author], 'module' => key[:module],
46
+ touches: value[:touches], churn: value[:churn], releaseDate: fist_commit_date,
47
+ commits_group_id: commits_group_id }
48
+ end
49
+ developer_metrics
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+
3
+ module Diggit
4
+ module DevelopersActivity
5
+ module ActivityExtractor
6
+ # Deals with authors identity merging
7
+ module Authors
8
+ extend self
9
+
10
+ def read_options(source_options)
11
+ @authors_merge = {}
12
+ source_options['authors'].each_pair do |k, v|
13
+ @authors_merge[k.downcase] = v.downcase
14
+ end
15
+ end
16
+
17
+ def get_author(commit)
18
+ author = commit.author[:name].downcase
19
+ ((defined? @authors_merge) && (@authors_merge.key? author)) ? @authors_merge[author] : author
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+
3
+ require 'diggit/developers_activity/activity_extractor/renames'
4
+
5
+ module Diggit
6
+ module DevelopersActivity
7
+ module ActivityExtractor
8
+ # Methods retrieving the module associated to a file.
9
+ module Modules
10
+ extend self
11
+
12
+ MODULES_REGEXP = "modules"
13
+ FILE_FILTER = "file-filter"
14
+
15
+ def read_options(source, source_options, db)
16
+ @source = source
17
+ @db = db
18
+ @release_files = files_from_cloc_analysis
19
+ @modules_regexp = source_options.key?(MODULES_REGEXP) ? source_options[MODULES_REGEXP].map { |m| Regexp.new m } : []
20
+ @file_filter = Regexp.new source_options[FILE_FILTER]
21
+ @file_filter ||= //
22
+ end
23
+
24
+ def ignore_file?(path)
25
+ !@release_files.include?(path) || (@file_filter =~ path).nil?
26
+ end
27
+
28
+ def get_module(path)
29
+ path = Renames.apply(path)
30
+
31
+ return nil if ignore_file?(path)
32
+ @modules_regexp.each do |module_regexp|
33
+ return module_regexp.to_s if module_regexp =~ path
34
+ end
35
+
36
+ path
37
+ end
38
+
39
+ def get_patch_module(patch)
40
+ file = patch.delta.old_file[:path]
41
+ get_module(file)
42
+ end
43
+
44
+ def files_from_cloc_analysis
45
+ release_files = Set.new
46
+ cloc_source = @db.db['cloc-file'].find_one({ source: @source })
47
+ cloc_source["cloc"].each do |cloc_file|
48
+ release_files << cloc_file["path"]
49
+ end
50
+ release_files
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,70 @@
1
+ # encoding: utf-8
2
+
3
+ require 'diggit/developers_activity'
4
+
5
+ module Diggit
6
+ module DevelopersActivity
7
+ module ActivityExtractor
8
+ # Stores file renaming operations.
9
+ # Allows to retrieve the initial path of a file after having performed a diff on the renaming commits.
10
+ #
11
+ # @since 0.0.1
12
+ module Renames
13
+ extend self
14
+
15
+ def hash
16
+ @renames_hash ||= {}
17
+ end
18
+
19
+ def clear
20
+ @renames_hash = {}
21
+ end
22
+
23
+ # Adds a rename operation to the list, if the rename does not create a cycle
24
+ #
25
+ # @return true if the rename was added, false otherwise
26
+ def add(src_path, dest_path)
27
+ # check for cycle, ie, if there is a rename path from dest to src
28
+ path = dest_path
29
+ while hash.key? path
30
+ path = hash[path]
31
+ return false if path == src_path
32
+ end
33
+
34
+ hash[src_path] = dest_path
35
+ true
36
+ end
37
+
38
+ # Apply all renaming operations found on the given path
39
+ #
40
+ # @return the path of the file at the S0 snapshot
41
+ def apply(path)
42
+ path = hash[path] while hash.key? path
43
+ path
44
+ end
45
+
46
+ def extract_commit_renames(commit, walk_backwards = true)
47
+ commit.parents.each do |parent|
48
+ diff = parent.diff(commit, DIFF_OPTIONS)
49
+ diff.find_similar!(DIFF_RENAME_OPTIONS)
50
+ diff.each do |patch|
51
+ next unless patch.delta.renamed?
52
+ if walk_backwards
53
+ renamed_path = patch.delta.new_file[:path]
54
+ new_path = patch.delta.old_file[:path]
55
+ else
56
+ new_path = patch.delta.new_file[:path]
57
+ renamed_path = patch.delta.old_file[:path]
58
+ end
59
+ add(renamed_path, new_path)
60
+ end
61
+ end
62
+ end
63
+
64
+ def extract_renames(walker, walk_backwards = true)
65
+ walker.each { |commit| extract_commit_renames(commit, walk_backwards) }
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end