Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/fetchcode/package_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def _get_github_packages(purl, version_regex, ignored_tag_regex, default_package

download_url = archive_download_url.format(org=purl.namespace, name=purl.name, tag_name=tag)

date = date.strftime("%Y-%m-%dT%H:%M:%S")
date = date.strftime("%Y-%m-%dT%H:%M:%S") if date else None
package_dict.update(
{
"download_url": download_url,
Expand Down
31 changes: 31 additions & 0 deletions tests/test_github_missing_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# fetchcode is a free software tool from nexB Inc. and others.
# Visit https://github.com/aboutcode-org/fetchcode for support and download.

# Copyright (c) nexB Inc. and others. All rights reserved.
# http://nexb.com and http://aboutcode.org

# This software is licensed under the Apache License version 2.0.

# You may not use this software except in compliance with the License.
# You may obtain a copy of the License at:
# http://apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

from packageurl import PackageURL

from fetchcode import package_util
from fetchcode.packagedcode_models import Package


def test_github_package_without_release_date(monkeypatch):
monkeypatch.setattr(
package_util.utils, "fetch_github_tags_gql", lambda purl: [("v1.2.3", None)]
)
purl = PackageURL("github", "example", "project")
packages = list(package_util.get_github_packages(purl, None, None, Package(**purl.to_dict())))
assert len(packages) == 1
assert packages[0].version == "1.2.3"
assert packages[0].release_date is None