Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9dff54a
Create junction from Scripts to bin
chinyeungli Jun 17, 2021
b735a3f
Merge pull request #26 from nexB/windows-junction
pombredanne Jun 17, 2021
77ce5e4
Check for deps in local thirdparty directory #31
JonoYang Aug 31, 2021
fa13562
Merge pull request #32 from nexB/install-from-thirdparty-dir
JonoYang Aug 31, 2021
1bcaaa5
Enforce use of requirements.txt #34
JonoYang Sep 1, 2021
e9067c8
Add scripts from scancode-toolkit/etc/release/ #33
JonoYang Sep 2, 2021
0e1f56b
Normalize license in load_pkginfo_data #33
JonoYang Sep 2, 2021
288532d
Add --init option to configure #33
JonoYang Sep 2, 2021
a5ae4f3
Update README.rst #33
JonoYang Sep 2, 2021
593e237
Use venv as virtual environment directory name #37
JonoYang Sep 3, 2021
9342bc1
Update configure.bat #33
JonoYang Sep 3, 2021
45e4a2a
Add placeholder requirements.txt files #33
JonoYang Sep 3, 2021
944fbae
Handle multiple options in configure #33
JonoYang Sep 3, 2021
3532b22
Fix path to aboutcode in utils_thirdparty.py #33
JonoYang Sep 4, 2021
9c78ddb
Update release notes in README.rst
JonoYang Sep 4, 2021
ebcfb93
Handle ExpressionParseError #33
JonoYang Sep 4, 2021
6ab9c10
Update README.rst
pombredanne Sep 7, 2021
bfdc6ff
Address review comments #33
JonoYang Sep 7, 2021
8583d7f
Merge pull request #39 from nexB/update-skeleton
JonoYang Sep 8, 2021
71d8dad
Update READMEs
JonoYang Sep 8, 2021
d3b8524
Merge pull request #40 from nexB/add-scripts-readme
JonoYang Sep 8, 2021
d2bafb9
Fixed #41 - Handled encoding issue when generating ABOUT files
chinyeungli Sep 15, 2021
c41196a
Merge pull request #42 from nexB/41_fix_encoding_error
chinyeungli Oct 4, 2021
5671563
Treat text files as text
pombredanne Oct 5, 2021
14f6a2d
Add helper to publish files in GH releases
pombredanne Oct 5, 2021
7aa7d4c
Do not issue warning if thirdparty dir is missing
pombredanne Oct 8, 2021
7f007db
Add failing tests
pombredanne Oct 8, 2021
8c86536
Do not fail with --replace-originals
pombredanne Oct 8, 2021
53e15fd
Filter event errors in replace_originals block
pombredanne Oct 8, 2021
d6e0596
Merge latest skeleton
pombredanne Oct 8, 2021
be6894d
Update CHANGELOG in prep for release
pombredanne Oct 8, 2021
1a22e57
Generate requirements
pombredanne Oct 8, 2021
cec17e7
Remove used empty skeleton directory
pombredanne Oct 8, 2021
6b71c99
Streamline test code
pombredanne Oct 8, 2021
c587f9c
Ue new venv dir for CLI tests
pombredanne Oct 8, 2021
c6866cc
Update CHANGELOG
pombredanne Oct 8, 2021
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
8 changes: 8 additions & 0 deletions src/extractcode/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,17 @@ def extract(
processed_events_append = processed_events.append
for event in extract_events:
yield event
if event.warnings or event.errors:
if TRACE:
logger.debug(
f'extract:replace_originals: {event} has errors. '
'not replacing originals'
)
continue
if replace_originals:
processed_events_append(event)


# move files around when done
if replace_originals:
for xevent in reversed(processed_events):
Expand Down
Binary file added tests/data/cli/replace-originals/issue6550.gz
Binary file not shown.
1 change: 1 addition & 0 deletions tests/data/cli/replace-originals/issue6550.gz.ABOUT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
download_url: https://golang.org/src/compress/gzip/testdata/issue6550.gz.base64
Binary file added tests/data/cli/replace-originals/rake.1.gz
Binary file not shown.
1 change: 1 addition & 0 deletions tests/data/cli/replace-originals/rake.1.gz.ABOUT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
download_url: https://github.com/ruby/rake/blob/v0.9.2.2/doc/rake.1.gz?raw=true
Binary file not shown.
1 change: 1 addition & 0 deletions tests/data/extract/replace-originals/issue6550.gz.ABOUT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
download_url: https://golang.org/src/compress/gzip/testdata/issue6550.gz.base64
Binary file added tests/data/extract/replace-originals/rake.1.gz
Binary file not shown.
1 change: 1 addition & 0 deletions tests/data/extract/replace-originals/rake.1.gz.ABOUT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
download_url: https://github.com/ruby/rake/blob/v0.9.2.2/doc/rake.1.gz?raw=true
18 changes: 18 additions & 0 deletions tests/test_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,24 @@ def test_extract_tree_recursive_replace_originals(self):
check_no_error(result)
check_files(test_dir, expected)

def test_extract_with_replace_originals_does_not_fail_with_gz_with_trailing(self):
expected = ('rake.1.gz',)
test_dir = self.get_test_loc('extract/replace-originals/rake.1.gz', copy=True)
result = list(extract.extract(test_dir, recurse=True, replace_originals=True))
r = result[-1]
assert r.errors and all(e.startswith('Not a gzipped file') for e in r.errors)
assert not r.warnings
check_files(test_dir, expected)

def test_extract_with_replace_originals_does_not_fail_with_corrupted_archive(self):
expected = ('issue6550.gz',)
test_dir = self.get_test_loc('extract/replace-originals/issue6550.gz', copy=True)
result = list(extract.extract(test_dir, recurse=True, replace_originals=True))
r = result[-1]
assert r.errors and all(e.startswith('Error') for e in r.errors)
assert not r.warnings
check_files(test_dir, expected)

def test_extract_tree_shallow_then_recursive(self):
shallow = (
'a/a.tar.gz',
Expand Down
16 changes: 16 additions & 0 deletions tests/test_extractcode_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,22 @@ def test_extractcode_command_can_ignore():
assert sorted(expected) == sorted(file_result)


def test_extractcode_command_does_not_crash_with_replace_originals_and_corrupted_archives():
test_dir = test_env.get_test_loc('cli/replace-originals', copy=True)
result = run_extract(['--replace-originals', '--verbose', test_dir] , expected_rc=1)

assert not os.path.exists(os.path.join(test_dir, 'rake.1.gz-extract'))
assert 'rake.1.gz' in result.stdout

assert 'Extracting archives...' in result.stderr
assert 'ERROR extracting' in result.stderr
assert 'rake.1.gz' in result.stderr
assert 'Not a gzipped file ' in result.stderr
assert 'issue6550.gz' in result.stderr
assert ' too many length or distance symbols' in result.stderr
assert 'Extracting done.' in result.stderr


@pytest.mark.skipif(on_windows, reason='FIXME: this test fails on Windows until we have support for long file names.')
def test_extractcode_command_can_extract_nuget():
test_dir = test_env.get_test_loc('cli/extract_nuget', copy=True)
Expand Down