Skip to content

Commit 0efe50f

Browse files
Return sha1_git checksum for all files as info
Reference: #624 Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
1 parent 0c7022e commit 0efe50f

File tree

73 files changed

+669
-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.

73 files changed

+669
-50
lines changed

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,

tests/formattedcode/data/common/manifests-expected.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,7 @@
10181018
"sha1": null,
10191019
"md5": null,
10201020
"sha256": null,
1021+
"sha1_git": null,
10211022
"mime_type": null,
10221023
"file_type": null,
10231024
"programming_language": null,
@@ -1052,6 +1053,7 @@
10521053
"sha1": null,
10531054
"md5": null,
10541055
"sha256": null,
1056+
"sha1_git": null,
10551057
"mime_type": null,
10561058
"file_type": null,
10571059
"programming_language": null,
@@ -1088,6 +1090,7 @@
10881090
"sha1": "82107f6781df8da9aa7cb60abc649208256af5cb",
10891091
"md5": "e79938fe4e630b02e3526c0195292cc6",
10901092
"sha256": "f94648bd92ddf2464e62c56c3833b36927fa8b9803e8ebf3e4cfa7f2d797f3ad",
1093+
"sha1_git": "614191600be349e61331a3a0eb2b883493f0db0f",
10911094
"mime_type": "text/xml",
10921095
"file_type": "XML 1.0 document, ASCII text",
10931096
"programming_language": null,
@@ -1216,6 +1219,7 @@
12161219
"sha1": null,
12171220
"md5": null,
12181221
"sha256": null,
1222+
"sha1_git": null,
12191223
"mime_type": null,
12201224
"file_type": null,
12211225
"programming_language": null,
@@ -1250,6 +1254,7 @@
12501254
"sha1": "0ed61bf6912407a143ce96c95bea56ad13463f5b",
12511255
"md5": "427e6d3b579b128fed50328ac65b698e",
12521256
"sha256": "d292aa647dc82e007ba319c878ec182d6f235f0a923cfe012ffc0ae8b7fa23be",
1257+
"sha1_git": "fee016dc24204e079cb9e0217d4439d73e1398ac",
12531258
"mime_type": "application/json",
12541259
"file_type": "JSON data",
12551260
"programming_language": null,
@@ -1550,6 +1555,7 @@
15501555
"sha1": null,
15511556
"md5": null,
15521557
"sha256": null,
1558+
"sha1_git": null,
15531559
"mime_type": null,
15541560
"file_type": null,
15551561
"programming_language": null,
@@ -1584,6 +1590,7 @@
15841590
"sha1": "e6acddf907b7089d197d9d46879cd18ffb8f5198",
15851591
"md5": "5ba816691af915c02567f459ae26ebd6",
15861592
"sha256": "11129bc3bbf44b2567307ad13a31bc231f08416919e36bbdeabb9195b3e6ad58",
1593+
"sha1_git": "99128a9e08f5a23c650d83af5dcf40c3b976753d",
15871594
"mime_type": "application/json",
15881595
"file_type": "JSON data",
15891596
"programming_language": null,
@@ -1774,6 +1781,7 @@
17741781
"sha1": null,
17751782
"md5": null,
17761783
"sha256": null,
1784+
"sha1_git": null,
17771785
"mime_type": null,
17781786
"file_type": null,
17791787
"programming_language": null,
@@ -1808,6 +1816,7 @@
18081816
"sha1": "5507192502255517e006c531d07dd84dc2325be8",
18091817
"md5": "6795bed0c9c6b6cb915bfa959a2d1d4a",
18101818
"sha256": "4378d297df9fcb4f65fdcd1299e17eef7db86883baf149bc41b0335f943cf006",
1819+
"sha1_git": "887bd3bfe3bdba0c8f737a69df38454b3d489ac1",
18111820
"mime_type": "text/x-script.python",
18121821
"file_type": "Python script, ASCII text executable",
18131822
"programming_language": "Python",

tests/formattedcode/data/common/manifests-expected.jsonlines

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
"system_environment": {
2121
"operating_system": "linux",
2222
"cpu_architecture": "64",
23-
"platform": "Linux-6.8.0-52-generic-x86_64-with-glibc2.35",
24-
"platform_version": "#53~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Jan 15 19:18:46 UTC 2",
25-
"python_version": "3.12.9 (main, Feb 20 2025, 19:13:20) [GCC 11.4.0]"
23+
"platform": "Linux-5.15.0-141-generic-x86_64-with-glibc2.35",
24+
"platform_version": "#151-Ubuntu SMP Sun May 18 21:35:19 UTC 2025",
25+
"python_version": "3.10.12 (main, Feb 4 2025, 14:57:36) [GCC 11.4.0]"
2626
},
2727
"spdx_license_list_version": "3.26",
2828
"files_count": 4
@@ -1056,6 +1056,7 @@
10561056
"sha1": null,
10571057
"md5": null,
10581058
"sha256": null,
1059+
"sha1_git": null,
10591060
"mime_type": null,
10601061
"file_type": null,
10611062
"programming_language": null,
@@ -1094,6 +1095,7 @@
10941095
"sha1": null,
10951096
"md5": null,
10961097
"sha256": null,
1098+
"sha1_git": null,
10971099
"mime_type": null,
10981100
"file_type": null,
10991101
"programming_language": null,
@@ -1134,6 +1136,7 @@
11341136
"sha1": "82107f6781df8da9aa7cb60abc649208256af5cb",
11351137
"md5": "e79938fe4e630b02e3526c0195292cc6",
11361138
"sha256": "f94648bd92ddf2464e62c56c3833b36927fa8b9803e8ebf3e4cfa7f2d797f3ad",
1139+
"sha1_git": "614191600be349e61331a3a0eb2b883493f0db0f",
11371140
"mime_type": "text/xml",
11381141
"file_type": "XML 1.0 document, ASCII text",
11391142
"programming_language": null,
@@ -1266,6 +1269,7 @@
12661269
"sha1": null,
12671270
"md5": null,
12681271
"sha256": null,
1272+
"sha1_git": null,
12691273
"mime_type": null,
12701274
"file_type": null,
12711275
"programming_language": null,
@@ -1304,6 +1308,7 @@
13041308
"sha1": "0ed61bf6912407a143ce96c95bea56ad13463f5b",
13051309
"md5": "427e6d3b579b128fed50328ac65b698e",
13061310
"sha256": "d292aa647dc82e007ba319c878ec182d6f235f0a923cfe012ffc0ae8b7fa23be",
1311+
"sha1_git": "fee016dc24204e079cb9e0217d4439d73e1398ac",
13071312
"mime_type": "application/json",
13081313
"file_type": "JSON data",
13091314
"programming_language": null,
@@ -1608,6 +1613,7 @@
16081613
"sha1": null,
16091614
"md5": null,
16101615
"sha256": null,
1616+
"sha1_git": null,
16111617
"mime_type": null,
16121618
"file_type": null,
16131619
"programming_language": null,
@@ -1646,6 +1652,7 @@
16461652
"sha1": "e6acddf907b7089d197d9d46879cd18ffb8f5198",
16471653
"md5": "5ba816691af915c02567f459ae26ebd6",
16481654
"sha256": "11129bc3bbf44b2567307ad13a31bc231f08416919e36bbdeabb9195b3e6ad58",
1655+
"sha1_git": "99128a9e08f5a23c650d83af5dcf40c3b976753d",
16491656
"mime_type": "application/json",
16501657
"file_type": "JSON data",
16511658
"programming_language": null,
@@ -1840,6 +1847,7 @@
18401847
"sha1": null,
18411848
"md5": null,
18421849
"sha256": null,
1850+
"sha1_git": null,
18431851
"mime_type": null,
18441852
"file_type": null,
18451853
"programming_language": null,
@@ -1878,6 +1886,7 @@
18781886
"sha1": "5507192502255517e006c531d07dd84dc2325be8",
18791887
"md5": "6795bed0c9c6b6cb915bfa959a2d1d4a",
18801888
"sha256": "4378d297df9fcb4f65fdcd1299e17eef7db86883baf149bc41b0335f943cf006",
1889+
"sha1_git": "887bd3bfe3bdba0c8f737a69df38454b3d489ac1",
18811890
"mime_type": "text/x-script.python",
18821891
"file_type": "Python script, ASCII text executable",
18831892
"programming_language": "Python",

tests/formattedcode/data/common/manifests-expected.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ headers:
2929
system_environment:
3030
operating_system: linux
3131
cpu_architecture: 64
32-
platform: Linux-6.8.0-52-generic-x86_64-with-glibc2.35
33-
platform_version: '#53~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Jan 15 19:18:46 UTC 2'
34-
python_version: 3.12.9 (main, Feb 20 2025, 19:13:20) [GCC 11.4.0]
32+
platform: Linux-5.15.0-141-generic-x86_64-with-glibc2.35
33+
platform_version: '#151-Ubuntu SMP Sun May 18 21:35:19 UTC 2025'
34+
python_version: 3.10.12 (main, Feb 4 2025, 14:57:36) [GCC 11.4.0]
3535
spdx_license_list_version: '3.26'
3636
files_count: 4
3737
summary:
@@ -1873,6 +1873,7 @@ files:
18731873
sha1:
18741874
md5:
18751875
sha256:
1876+
sha1_git:
18761877
mime_type:
18771878
file_type:
18781879
programming_language:
@@ -1912,6 +1913,7 @@ files:
19121913
sha1:
19131914
md5:
19141915
sha256:
1916+
sha1_git:
19151917
mime_type:
19161918
file_type:
19171919
programming_language:
@@ -1952,6 +1954,7 @@ files:
19521954
sha1: 82107f6781df8da9aa7cb60abc649208256af5cb
19531955
md5: e79938fe4e630b02e3526c0195292cc6
19541956
sha256: f94648bd92ddf2464e62c56c3833b36927fa8b9803e8ebf3e4cfa7f2d797f3ad
1957+
sha1_git: 614191600be349e61331a3a0eb2b883493f0db0f
19551958
mime_type: text/xml
19561959
file_type: XML 1.0 document, ASCII text
19571960
programming_language:
@@ -2087,6 +2090,7 @@ files:
20872090
sha1:
20882091
md5:
20892092
sha256:
2093+
sha1_git:
20902094
mime_type:
20912095
file_type:
20922096
programming_language:
@@ -2126,6 +2130,7 @@ files:
21262130
sha1: 0ed61bf6912407a143ce96c95bea56ad13463f5b
21272131
md5: 427e6d3b579b128fed50328ac65b698e
21282132
sha256: d292aa647dc82e007ba319c878ec182d6f235f0a923cfe012ffc0ae8b7fa23be
2133+
sha1_git: fee016dc24204e079cb9e0217d4439d73e1398ac
21292134
mime_type: application/json
21302135
file_type: JSON data
21312136
programming_language:
@@ -2398,6 +2403,7 @@ files:
23982403
sha1:
23992404
md5:
24002405
sha256:
2406+
sha1_git:
24012407
mime_type:
24022408
file_type:
24032409
programming_language:
@@ -2437,6 +2443,7 @@ files:
24372443
sha1: e6acddf907b7089d197d9d46879cd18ffb8f5198
24382444
md5: 5ba816691af915c02567f459ae26ebd6
24392445
sha256: 11129bc3bbf44b2567307ad13a31bc231f08416919e36bbdeabb9195b3e6ad58
2446+
sha1_git: 99128a9e08f5a23c650d83af5dcf40c3b976753d
24402447
mime_type: application/json
24412448
file_type: JSON data
24422449
programming_language:
@@ -2619,6 +2626,7 @@ files:
26192626
sha1:
26202627
md5:
26212628
sha256:
2629+
sha1_git:
26222630
mime_type:
26232631
file_type:
26242632
programming_language:
@@ -2658,6 +2666,7 @@ files:
26582666
sha1: 5507192502255517e006c531d07dd84dc2325be8
26592667
md5: 6795bed0c9c6b6cb915bfa959a2d1d4a
26602668
sha256: 4378d297df9fcb4f65fdcd1299e17eef7db86883baf149bc41b0335f943cf006
2669+
sha1_git: 887bd3bfe3bdba0c8f737a69df38454b3d489ac1
26612670
mime_type: text/x-script.python
26622671
file_type: Python script, ASCII text executable
26632672
programming_language: Python

0 commit comments

Comments
 (0)