Skip to content

Commit 15b4f7d

Browse files
Update CHANGELOG, docs and CLI option tests
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
1 parent cd54687 commit 15b4f7d

File tree

5 files changed

+53
-5
lines changed

5 files changed

+53
-5
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ v33.0.0 (next next, roadmap)
3737
v32.1.0 (next, roadmap)
3838
----------------------------
3939

40+
New CLI options:
41+
42+
- A new CLI option ``--package-only`` has been added which performs
43+
a faster package scan by skipping the package assembly step and
44+
also skipping license/copyright detection on package metadata.
45+
4046
Major API/other changes:
4147

4248
- Output Format Version updated to 3.1.0 (minor version bump)

docs/source/rst_snippets/basic_options.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ documenting a program's options. For example:
3333
--system-package Scan ``<input>`` for installed system package
3434
databases.
3535

36+
--package-only Scan ``<input>`` for system and application
37+
only for package metadata, without license/
38+
copyright detection and package assembly.
39+
3640
-e, --email Scan ``<input>`` for emails.
3741

3842
Sub-Options:

src/packagedcode/plugin_package.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,11 @@ class PackageScanner(ScanPlugin):
166166
),
167167
is_flag=True,
168168
default=False,
169+
conflicting_options=['license', 'summary', 'package', 'system_package'],
169170
help=(
170-
'Only detect package information and skip license/copyright detection steps, '
171-
'in application package and dependency manifests, lockfiles and related data.'
171+
'Scan for system and application package metadata and skip '
172+
'license/copyright detection steps and codebase level package '
173+
'creation.'
172174
),
173175
help_group=SCAN_GROUP,
174176
sort_order=22,

tests/packagedcode/test_plugin_package.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,42 @@ def test_package_list_command(self, regen=REGEN_TEST_FIXTURES):
227227
ef.write(result.output)
228228
assert result.output == open(expected_file).read()
229229

230+
def test_plugin_package_only_fails_with_license_scan(self):
231+
test_dir = self.get_test_loc('maven2')
232+
result_file = self.get_temp_file('json')
233+
try:
234+
run_scan_click(['--package-only', '--license', test_dir, '--json', result_file])
235+
raise Exception("This SCAN should raise an AssertionError for conflicting CLI options")
236+
except AssertionError:
237+
pass
238+
239+
def test_plugin_package_only_fails_with_summary_scan(self):
240+
test_dir = self.get_test_loc('maven2')
241+
result_file = self.get_temp_file('json')
242+
try:
243+
run_scan_click(['--package-only', '--summary', '--classify', test_dir, '--json', result_file])
244+
raise Exception("This SCAN should raise an AssertionError for conflicting CLI options")
245+
except AssertionError:
246+
pass
247+
248+
def test_plugin_package_only_fails_with_package_scan(self):
249+
test_dir = self.get_test_loc('maven2')
250+
result_file = self.get_temp_file('json')
251+
try:
252+
run_scan_click(['--package-only', '--package', test_dir, '--json', result_file])
253+
raise Exception("This SCAN should raise an AssertionError for conflicting CLI options")
254+
except AssertionError:
255+
pass
256+
257+
def test_plugin_package_only_fails_with_system_package_scan(self):
258+
test_dir = self.get_test_loc('maven2')
259+
result_file = self.get_temp_file('json')
260+
try:
261+
run_scan_click(['--package-only', '--system-package', test_dir, '--json', result_file])
262+
raise Exception("This SCAN should raise an AssertionError for conflicting CLI options")
263+
except AssertionError:
264+
pass
265+
230266
def test_system_package_get_installed_packages(self):
231267
test_dir = self.extract_test_tar('debian/basic-rootfs.tar.gz')
232268
expected_file = self.get_test_loc('plugin/get_installed_packages-expected.json')

tests/scancode/data/help/help.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Options:
1212
-p, --package Scan <input> for application package and dependency
1313
manifests, lockfiles and related data.
1414
--system-package Scan <input> for installed system package databases.
15-
--package-only Only detect package information and skip license/copyright
16-
detection steps, in application package and dependency
17-
manifests, lockfiles and related data.
15+
--package-only Scan for system and application package metadata and skip
16+
license/copyright detection steps and codebase level package
17+
creation.
1818
-c, --copyright Scan <input> for copyrights.
1919

2020
other scans:

0 commit comments

Comments
 (0)