Skip to content

Commit d7875d7

Browse files
Return sha1_git checksum for all files as info
Reference: #624 Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
1 parent 0c7022e commit d7875d7

File tree

92 files changed

+736
-50
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+736
-50
lines changed

CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ v33.0.0 (next next, roadmap)
4646
- Update ABOUT files to adapt the ABOUT File Specification.
4747
See https://github.com/aboutcode-org/scancode-toolkit/issues/4181
4848

49+
- Also return sha1_git checksums for each files with ``--info`` plugin.
50+
https://github.com/aboutcode-org/scancode-toolkit/issues/624
51+
4952

5053
v32.3.3 - 2025-03-06
5154
--------------------

docs/source/cli-reference/output-format.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ following options.
141141
"date": "2019-02-12",
142142
"sha1": "fca4540d490fff36bb90fd801cf9cd8fc695bb17",
143143
"md5": "a980b61c1e8be68d5cdb1236ba6b43e7",
144+
"sha1_git": "d9a10c0d8e868ebf8da0b3dc95bb0be634c34bfe",
144145
"mime_type": "text/x-c++",
145146
"file_type": "C++ source, ASCII text",
146147
"programming_language": "C++",
@@ -481,6 +482,7 @@ Comparing Different ``json`` Output Formats
481482
- size,
482483
- sha1,
483484
- md5,
485+
- sha1_git,
484486
- files_count,
485487
- mime_type,
486488
- file_type,

docs/source/cli-reference/scan-options-post.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,7 @@ To see all plugins available via command line help, use ``--plugins``.
10601060
"sha1": null,
10611061
"md5": null,
10621062
"sha256": null,
1063+
"sha1_git": null,
10631064
"mime_type": null,
10641065
"file_type": null,
10651066
"programming_language": null,

docs/source/cli-reference/synopsis.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ A sample JSON output file structure will look like::
156156
"date": "2019-02-12",
157157
"sha1": "2e07e32c52d607204fad196052d70e3d18fb8636",
158158
"md5": "effc6856ef85a9250fb1a470792b3f38",
159+
"sha1_git": "d9a10c0d8e868ebf8da0b3dc95bb0be634c34bfe",
159160
"mime_type": "text/plain",
160161
"file_type": "ASCII text",
161162
"programming_language": null,

src/scancode/api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,14 @@ def get_file_info(location, **kwargs):
330330
result['date'] = get_last_modified_date(location) or None
331331
result['size'] = getsize(location) or 0
332332

333-
sha1, md5, sha256 = multi_checksums(location, ('sha1', 'md5', 'sha256')).values()
333+
sha1, md5, sha256, sha1_git = multi_checksums(
334+
location=location,
335+
checksum_names=('sha1', 'md5', 'sha256', 'sha1_git')
336+
).values()
334337
result['sha1'] = sha1
335338
result['md5'] = md5
336339
result['sha256'] = sha256
340+
result['sha1_git'] = sha1_git
337341

338342
collector = get_type(location)
339343
result['mime_type'] = collector.mimetype_file or None

src/scancode/plugin_info.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class InfoScanner(ScanPlugin):
2727
('sha1', attr.ib(default=None, repr=False)),
2828
('md5', attr.ib(default=None, repr=False)),
2929
('sha256', attr.ib(default=None, repr=False)),
30+
('sha1_git', attr.ib(default=None, repr=False)),
3031
('mime_type', attr.ib(default=None, repr=False)),
3132
('file_type', attr.ib(default=None, repr=False)),
3233
('programming_language', attr.ib(default=None, repr=False)),

tests/cluecode/data/plugin_filter_clues/filtered-expected.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"sha1": "c4d6f133413f1ea9d3c436fb797f9060c8640c04",
3535
"md5": "55a970437979ffe95e7b8ee6e51abb0c",
3636
"sha256": "ebdef41bf0f5bd7d378e4f76052e02156ce1c80ce67f89209b018a3fca8a071c",
37+
"sha1_git": "c6cc3f85376fd76bdebcc4fee6e9137e80bd8691",
3738
"mime_type": "text/plain",
3839
"file_type": "ASCII text",
3940
"programming_language": null,

tests/cluecode/data/plugin_filter_clues/filtered-expected2.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"sha1": "c43ffed01990c30300e07231790ace9f103ff7d7",
3535
"md5": "9946f7dcaf5066f2fb17e682e0326090",
3636
"sha256": "58416604a57e2e2625b802ac8c751c61763ae3d279c9c75d7c3bb55a3782cc6c",
37+
"sha1_git": "9956de3f204ca2d5c46b77e70c4c6bf9509f6dd8",
3738
"mime_type": "text/plain",
3839
"file_type": "ASCII text",
3940
"programming_language": null,

tests/cluecode/data/plugin_filter_clues/filtered-expected3.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"sha1": "9db841f62fdb2372f5f474bb75366140a00c62ca",
3535
"md5": "3fdbe85d79aa58aaeab119505f2007b6",
3636
"sha256": "408dfe8f9a70ea7bc9feaa9f77fb731ada0c26dc39008fdc5ead52d0442c656f",
37+
"sha1_git": "3ed0b925a62cbabad29cda7743c513d2ed557dc2",
3738
"mime_type": "text/plain",
3839
"file_type": "ASCII text",
3940
"programming_language": "verilog",

tests/cluecode/data/plugin_filter_clues/filtered-expected4.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
"sha1": "8a2e40b4eb23cc05a0b78330d919a7ffacde7a9a",
147147
"md5": "d5d03e14130735213e0532277df33cab",
148148
"sha256": "e4bd79e88b577d66d351597c0d4114b9ee2e31f0544795e87a88ca1b0dd38383",
149+
"sha1_git": "e7c0b65bcdb17888027d0b53a1f65ad61b238245",
149150
"mime_type": "text/plain",
150151
"file_type": "ASCII text",
151152
"programming_language": null,

0 commit comments

Comments
 (0)