Skip to content

Commit 6a38f0e

Browse files
committed
suggestions applied
Signed-off-by: NucleonGodX <racerpro41@gmail.com>
1 parent b99f789 commit 6a38f0e

18 files changed

Lines changed: 725 additions & 903 deletions

File tree

src/packagedcode/buildpack.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,39 @@ def parse(cls, location, package_only=False):
3838

3939
buildpack_id = buildpack.get("id")
4040
name = buildpack.get("name")
41+
namespace = None
4142

42-
if buildpack_id:
43+
if buildpack_id and "/" in buildpack_id:
4344
namespace, name = buildpack_id.split("/", 1)
45+
version = buildpack.get("version")
46+
if version and "{{" in version and "}}" in version:
47+
version = None
4448

4549
# Initialize common package data
4650
package_data = dict(
4751
datasource_id=cls.datasource_id,
4852
type=cls.default_package_type,
4953
name=name,
50-
version=buildpack.get("version"),
54+
namespace=namespace,
55+
version=version,
5156
description=buildpack.get("description"),
5257
homepage_url=buildpack.get("homepage"),
5358
keywords=buildpack.get("keywords", []),
5459
extracted_license_statement=None,
55-
dependencies=[],
56-
extra_data={}
60+
extra_data={},
5761
)
5862

5963
if api_version:
6064
package_data["extra_data"]["api_version"] = api_version
6165

66+
if buildpack_id:
67+
package_data["extra_data"]["id"] = buildpack_id
68+
69+
metadata = data.get("metadata", {})
70+
include_files = metadata.get("include-files", [])
71+
if include_files:
72+
package_data["extra_data"]["include_files"] = include_files
73+
6274
# Handle Paketo-specific fields if present
6375
if "api" in data:
6476
cls.handle_paketo_buildpack(data, buildpack, package_data)
@@ -71,12 +83,7 @@ def parse(cls, location, package_only=False):
7183

7284
@staticmethod
7385
def handle_paketo_buildpack(data, buildpack, package_data):
74-
buildpack_id = buildpack.get("id")
75-
if buildpack_id:
76-
package_data["extra_data"]["id"] = buildpack_id
77-
7886
package_data.update({
79-
"version": buildpack.get("version"),
8087
"description": buildpack.get("description"),
8188
"homepage_url": buildpack.get("homepage"),
8289
"keywords": buildpack.get("keywords", []),
@@ -91,7 +98,6 @@ def handle_paketo_buildpack(data, buildpack, package_data):
9198
]
9299
package_data["extracted_license_statement"] = "\n".join(license_statements)
93100

94-
95101
dependencies = []
96102
metadata = data.get("metadata", {})
97103
metadata_dependencies = metadata.get("dependencies", [])
@@ -149,4 +155,4 @@ def handle_heroku_buildpack(data, buildpack, package_data):
149155
else:
150156
package_data["extra_data"]["ignore_files"] = []
151157

152-
package_data["description"] = f"Heroku buildpack for {buildpack.get('name')}"
158+
package_data["description"] = f"Heroku buildpack for {buildpack.get('name')}"

tests/packagedcode/data/buildpack/heroku-buildpacks/heroku-buildpack-java/expectedbuildpack.json

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
[
2+
{
3+
"type": "generic",
4+
"namespace": null,
5+
"name": "Java",
6+
"version": null,
7+
"qualifiers": {},
8+
"subpath": null,
9+
"primary_language": null,
10+
"description": "Heroku buildpack for Java",
11+
"release_date": null,
12+
"parties": [],
13+
"keywords": [],
14+
"homepage_url": null,
15+
"download_url": null,
16+
"size": null,
17+
"sha1": null,
18+
"md5": null,
19+
"sha256": null,
20+
"sha512": null,
21+
"bug_tracking_url": null,
22+
"code_view_url": null,
23+
"vcs_url": null,
24+
"copyright": null,
25+
"holder": null,
26+
"declared_license_expression": null,
27+
"declared_license_expression_spdx": null,
28+
"license_detections": [],
29+
"other_license_expression": null,
30+
"other_license_expression_spdx": null,
31+
"other_license_detections": [],
32+
"extracted_license_statement": null,
33+
"notice_text": null,
34+
"source_packages": [],
35+
"file_references": [],
36+
"is_private": false,
37+
"is_virtual": false,
38+
"extra_data": {
39+
"ignore_files": [
40+
"etc/",
41+
"spec/",
42+
"test/",
43+
".gitignore",
44+
".github/",
45+
"hatchet.json",
46+
"Gemfile",
47+
"Gemfile.lock"
48+
]
49+
},
50+
"dependencies": [],
51+
"repository_homepage_url": null,
52+
"repository_download_url": null,
53+
"api_data_url": null,
54+
"datasource_id": "buildpack_toml",
55+
"purl": "pkg:generic/Java"
56+
}
57+
]
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
[
2+
{
3+
"type": "generic",
4+
"namespace": null,
5+
"name": "PHP",
6+
"version": null,
7+
"qualifiers": {},
8+
"subpath": null,
9+
"primary_language": null,
10+
"description": "Heroku buildpack for PHP",
11+
"release_date": null,
12+
"parties": [],
13+
"keywords": [],
14+
"homepage_url": null,
15+
"download_url": null,
16+
"size": null,
17+
"sha1": null,
18+
"md5": null,
19+
"sha256": null,
20+
"sha512": null,
21+
"bug_tracking_url": null,
22+
"code_view_url": null,
23+
"vcs_url": null,
24+
"copyright": null,
25+
"holder": null,
26+
"declared_license_expression": null,
27+
"declared_license_expression_spdx": null,
28+
"license_detections": [],
29+
"other_license_expression": null,
30+
"other_license_expression_spdx": null,
31+
"other_license_detections": [],
32+
"extracted_license_statement": null,
33+
"notice_text": null,
34+
"source_packages": [],
35+
"file_references": [],
36+
"is_private": false,
37+
"is_virtual": false,
38+
"extra_data": {
39+
"ignore_files": [
40+
".github/",
41+
".gitignore",
42+
".rspec_parallel",
43+
"support/build/",
44+
"support/devcenter/",
45+
"test/",
46+
"Gemfile",
47+
"Gemfile.lock",
48+
"hatchet.json",
49+
"hatchet.lock",
50+
"requirements.txt"
51+
]
52+
},
53+
"dependencies": [],
54+
"repository_homepage_url": null,
55+
"repository_download_url": null,
56+
"api_data_url": null,
57+
"datasource_id": "buildpack_toml",
58+
"purl": "pkg:generic/PHP"
59+
}
60+
]

tests/packagedcode/data/buildpack/heroku-buildpacks/heroku-buildpack-php/expectedbuildpack.json renamed to tests/packagedcode/data/buildpack/heroku-buildpacks/heroku-results.json

File renamed without changes.

tests/packagedcode/data/buildpack/paketo-buildpacks/dotnet-execute/expectedbuildpack.json

Lines changed: 0 additions & 86 deletions
This file was deleted.

0 commit comments

Comments
 (0)