Skip to content

Commit

Permalink
fix bramch
Browse files Browse the repository at this point in the history
  • Loading branch information
oxeye-schmil committed Dec 13, 2023
1 parent 7529941 commit 6ba6590
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions images/scm_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ class InvalidRemoteURLRepositoryError(RepositoryError):


class RepositoryParameters:
def __init__(self, workdir: str, provider: str, description: str, license: str):
def __init__(
self,
workdir: str,
provider: str,
description: str,
repo_license: str,
branch: str,
):
repo = Repo(workdir)
if not repo or repo.bare:
logger.error(f"Got bare repository")
Expand All @@ -86,8 +93,8 @@ def __init__(self, workdir: str, provider: str, description: str, license: str):
self.organization = match_url.group("organization")
self.name = match_url.group("name")
self.description = description
self.license = license
self.branch = repo.active_branch.name
self.repo_license = repo_license
self.branch = branch


class CicdToolParameters(TypedDict):
Expand All @@ -96,7 +103,8 @@ class CicdToolParameters(TypedDict):
workdir: str
languages: str
description: str
license: str
repo_license: str
branch: str


# GENERAL
Expand Down Expand Up @@ -172,7 +180,8 @@ def setup_github(
workdir=workdir,
languages=json.dumps(languages),
description=repository_data.get("description", "None"),
license=repository_data.get("license", "None"),
repo_license=repository_data.get("license", "None"),
branch=os.environ.get("GITHUB_REF_NAME", "NA"),
)

return cicd_tool_parameters
Expand Down Expand Up @@ -204,7 +213,8 @@ def setup_gitlab(
workdir=workdir,
languages=json.dumps(languages),
description=repository_data.get("description", "None"),
license=repository_data.get("license", "None"),
repo_license=repository_data.get("license", "None"),
branch=os.environ.get("CI_COMMIT_REF_NAME", "NA"),
)
return cicd_tool_parameters

Expand All @@ -220,7 +230,8 @@ def setup_jenkins() -> Optional[CicdToolParameters]:
workdir=workdir,
languages="{}",
description="None",
license="None",
repo_license="None",
branch="",
)
return cicd_tool_parameters

Expand All @@ -235,7 +246,8 @@ def setup_azure() -> Optional[CicdToolParameters]:
workdir=workdir,
languages="{}",
description="None",
license="None",
repo_license="None",
branch="",
)

return cicd_tool_parameters
Expand All @@ -252,7 +264,8 @@ def setup_bitbucket() -> Optional[CicdToolParameters]:
workdir=workdir,
languages="{}",
description="None",
license="None",
repo_license="None",
branch="",
)

return cicd_tool_parameters
Expand Down Expand Up @@ -294,7 +307,8 @@ def setup(
workdir=cicd_tool_params["workdir"],
provider=cicd_tool_params["provider"],
description=cicd_tool_params["description"],
license=cicd_tool_params["license"],
repo_license=cicd_tool_params["repo_license"],
branch=cicd_tool_params["branch"],
)

return cicd_tool_params, repo_params
Expand Down Expand Up @@ -450,7 +464,7 @@ def upload_file(
f"--repository-organization '{repo_params.organization}' "
f"--repository-name '{repo_params.name}' "
f"--repository-description '{repo_params.description}' "
f"--repository-license '{repo_params.license}' "
f"--repository-license '{repo_params.repo_license}' "
f"--repository-branch '{repo_params.branch}' "
f"--repository-languages '{cicd_tool_params['languages']}' "
f"--repository-run-id '{run_id}' "
Expand Down

0 comments on commit 6ba6590

Please sign in to comment.