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
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ The following organizations or individuals have contributed to ScanCode:
- Lemo Shi @lemoshi
- Li Ha @linexb
- Mankaran Singh @MankaranSingh
- Marc-Etienne Vargenau @vargenau
- Martin Petkov @MartinPetkov
- Maximilian Huber @maxhbr
- Michael Herzog @mjherzog
Expand Down
5 changes: 4 additions & 1 deletion src/formattedcode/output_spdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,10 @@ def write_spdx(
file_entry = File(
spdx_id=f'SPDXRef-{sid}',
name=name)
file_entry.set_checksum(Checksum(ChecksumAlgorithm.SHA1, file_data.get('sha1') or ''))
if file_data.get('file_type') == 'empty':
file_entry.set_checksum(Checksum(ChecksumAlgorithm.SHA1, "da39a3ee5e6b4b0d3255bfef95601890afd80709"))
else:
file_entry.set_checksum(Checksum(ChecksumAlgorithm.SHA1, file_data.get('sha1') or ''))

file_license_detections = file_data.get('license_detections')
license_matches = get_matches_from_detection_mappings(file_license_detections)
Expand Down
9 changes: 8 additions & 1 deletion tests/formattedcode/test_output_spdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,18 @@ def test_output_spdx_rdf_can_handle_non_ascii_paths():
results = res.read()
assert 'han/据.svg' in results


def test_output_spdx_tv_can_handle_non_ascii_paths():
test_file = test_env.get_test_loc('spdx/unicode.json')
result_file = test_env.get_temp_file(extension='spdx', file_name='test_spdx')
run_scan_click(['--from-json', test_file, '--spdx-tv', result_file])
with io.open(result_file, encoding='utf-8') as res:
results = res.read()
assert 'han/据.svg' in results

def test_output_spdx_tv_sh1_of_empty_file():
test_dir = test_env.get_test_loc('spdx/empty/scan/somefile')
result_file = test_env.get_temp_file(extension='spdx', file_name='test_spdx')
run_scan_click([test_dir, '-clip', '--spdx-tv', result_file])
with io.open(result_file, encoding='utf-8') as res:
results = res.read()
assert 'FileChecksum: SHA1: da39a3ee5e6b4b0d3255bfef95601890afd80709' in results