Skip to content

Commit 19bd389

Browse files
committed
fix: correct licensee version, JSON parsing, and null type cast IN-1105
Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
1 parent 0f11470 commit 19bd389

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

scripts/services/docker/Dockerfile.git_integration

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,15 @@ RUN apt-get update && apt-get install -y \
8484
git \
8585
ripgrep \
8686
ruby \
87+
libgit2-1.1 \
8788
ruby-dev \
8889
build-essential \
90+
libgit2-dev \
91+
cmake \
92+
pkg-config \
8993
--no-install-recommends \
90-
&& gem install licensee -v '10.0.0' --no-document \
91-
&& apt-get remove --autoremove -y ruby-dev build-essential \
94+
&& gem install licensee -v '9.15.3' --no-document \
95+
&& apt-get remove --autoremove -y ruby-dev build-essential libgit2-dev cmake pkg-config \
9296
&& rm -rf /var/lib/apt/lists/*
9397

9498
ENV PYTHONUNBUFFERED=1 \

services/apps/git_integration/src/crowdgit/database/crud.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,10 @@ async def update_last_processed_commit(repo_id: str, commit_hash: str, branch: s
286286
async def update_repository_license(repository_id: str, license_spdx: str | None) -> None:
287287
sql_query = """
288288
UPDATE public.repositories
289-
SET license = $1,
289+
SET license = $1::varchar,
290290
"updatedAt" = NOW()
291291
WHERE id = $2
292-
AND ($1 IS NOT NULL OR license IS NULL)
292+
AND ($1::varchar IS NOT NULL OR license IS NULL)
293293
"""
294294
await execute(sql_query, (license_spdx, repository_id))
295295

services/apps/git_integration/src/crowdgit/services/license/license_service.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ async def detect(self, repo_path: str) -> str | None:
2727

2828
try:
2929
data = json.loads(output)
30-
matched = data.get("matched_license") or {}
31-
spdx_id = matched.get("spdx_id")
32-
confidence = matched.get("confidence")
30+
licenses = data.get("licenses") or []
31+
matched_files = data.get("matched_files") or []
32+
spdx_id = licenses[0].get("spdx_id") if licenses else None
33+
confidence = (matched_files[0].get("matcher") or {}).get("confidence") if matched_files else None
3334
if spdx_id:
3435
self.logger.info(f"License detected: {spdx_id} (confidence={confidence}) in {repo_path}")
3536
else:

0 commit comments

Comments
 (0)