Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions src/deltacode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def similarity(self):
)

def create_deltas(
self, new_resource, old_resource, new_path, old_path, score, status
self, new_resource, old_resource, score, status
):
"""
Creates the Delta Objects and appends them to the member list.
Expand Down Expand Up @@ -153,7 +153,7 @@ def determine_delta(self):
)
# If the resource is a file align its path

old_resource = self.codebase2.get_resource_from_path(path_new)
old_resource = self.codebase2.get_resource(path_new)
# Check in the old codebase weather a resource with such a path exists or not
# if it exists and their corresponding sha's are same then its an unmodified delta

Expand All @@ -163,7 +163,7 @@ def determine_delta(self):
paths.split(old_resource.path)[Delta.OLD_CODEBASE_OFFSET :]
)
self.create_deltas(
new_resource, old_resource, path_new, path_old, 0, "unmodified",
new_resource, old_resource, 0, "unmodified",
)
self.stats.num_unmodified += 1

Expand Down Expand Up @@ -196,8 +196,6 @@ def determine_delta(self):
self.create_deltas(
new_resource,
old_resource,
path_new,
path_old,
0,
"unmodified",
)
Expand All @@ -209,8 +207,6 @@ def determine_delta(self):
self.create_deltas(
new_resource,
old_resource,
path_new,
path_old,
20,
"modified",
)
Expand All @@ -225,8 +221,6 @@ def determine_delta(self):
self.create_deltas(
new_resource,
old_resource,
path_new,
path_old,
0,
"moved",
)
Expand All @@ -236,7 +230,7 @@ def determine_delta(self):
if ADDED:
# If none of the above criteria matches then the delta is an added one.
self.create_deltas(
new_resource, None, path_new, None, 100, "added",
new_resource, None, 100, "added",
)
self.stats.num_added += 1

Expand All @@ -253,7 +247,7 @@ def determine_delta(self):
]
)
self.create_deltas(
None, old_resource_remaining, None, path_old, 0, "removed",
None, old_resource_remaining, 0, "removed",
)
self.stats.num_removed += 1

Expand Down
2 changes: 1 addition & 1 deletion tests/data/deltacode/scan_modified_old_license_added.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
{
"path": "some/path/b/b1.py",
"type": "file",
"name": "b2.py",
"name": "b1.py",
"size": 200,
"sha1": "333647771481d39dd3a53f6dc210c26abac37748",
"licenses": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": "",
"copyrights": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a_modified",
"original_path": "",
"copyrights": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": "",
"copyrights": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a_modified",
"original_path": "",
"copyrights": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": "",
"copyrights": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": "",
"copyrights": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a_modified",
"original_path": "",
"copyrights": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": ""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a_modified",
"original_path": ""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": "",
"copyrights": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": "",
"copyrights": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": "",
"copyrights": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a_modified",
"original_path": "",
"copyrights": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": "",
"copyrights": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a_modified",
"original_path": "",
"copyrights": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": "",
"copyrights": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a_modified",
"original_path": "",
"copyrights": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": "",
"copyrights": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a_modified",
"original_path": "",
"copyrights": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": "",
"copyrights": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a_modified",
"original_path": "",
"copyrights": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": "",
"licenses": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a_modified",
"original_path": "",
"licenses": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": "",
"licenses": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a_modified",
"original_path": "",
"licenses": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": "",
"licenses": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a_modified",
"original_path": "",
"licenses": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": "",
"licenses": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a_modified",
"original_path": "",
"licenses": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,10 @@
},
"files_count": 2,
"files": [
{
"path":"test",
"name": "path",
"sha1": "c",
"original_path": "",
"licenses": [],
"copyrights": []
},
{
"path":"/test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": "",
"licenses": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{
"path":"test",
"name": "path",
"type": "directory",
"sha1": "c",
"original_path": "",
"licenses": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": "",
"licenses": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{
"path":"test",
"name": "test",
"type": "directory",
"sha1": "b",
"original_path": "",
"licenses": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": "",
"licenses": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a_modified",
"original_path": "",
"licenses": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": "",
"licenses": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a_modified",
"original_path": "",
"licenses": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{
"path":"test/path.txt",
"name": "path.txt",
"type": "file",
"sha1": "a",
"original_path": "",
"licenses": [
Expand Down
Loading