From 0c86dc49f5bea1114f60641f3ff052629ed197d0 Mon Sep 17 00:00:00 2001 From: Rob van der Leek <5324924+robvanderleek@users.noreply.github.com> Date: Thu, 12 Dec 2024 22:02:11 +0100 Subject: [PATCH 1/5] =?UTF-8?q?chore:=20=F0=9F=9A=A7=20Read=20repo=20info?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codelimit/__main__.py | 82 ++++++++++++++++++---------- codelimit/commands/report.py | 2 +- codelimit/common/Configuration.py | 3 + codelimit/common/GithubRepository.py | 15 +++++ codelimit/common/console.py | 3 + codelimit/common/utils.py | 33 ++++++++++- codelimit/utils.py | 21 +++++-- poetry.lock | 12 +++- pyproject.toml | 1 + tests/regression.py | 29 +++------- 10 files changed, 144 insertions(+), 57 deletions(-) create mode 100644 codelimit/common/GithubRepository.py create mode 100644 codelimit/common/console.py diff --git a/codelimit/__main__.py b/codelimit/__main__.py index 1c47584..904db4a 100755 --- a/codelimit/__main__.py +++ b/codelimit/__main__.py @@ -1,6 +1,7 @@ from pathlib import Path from typing import List, Annotated, Optional +import pyperclip import typer from click import Context from rich import print @@ -10,6 +11,8 @@ from codelimit.commands.report import report_command, ReportFormat from codelimit.commands.scan import scan_command from codelimit.common.Configuration import Configuration +from codelimit.common.utils import configure_github_repository +from codelimit.utils import success, info from codelimit.version import version @@ -26,13 +29,13 @@ def list_commands(self, ctx: Context): @cli.command(help="Check file(s)") def check( - paths: Annotated[List[Path], typer.Argument(exists=True)], - exclude: Annotated[ - Optional[list[str]], typer.Option(help="Glob patterns for exclusion") - ] = None, - quiet: Annotated[ - bool, typer.Option("--quiet", help="No output when successful") - ] = False, + paths: Annotated[List[Path], typer.Argument(exists=True)], + exclude: Annotated[ + Optional[list[str]], typer.Option(help="Glob patterns for exclusion") + ] = None, + quiet: Annotated[ + bool, typer.Option("--quiet", help="No output when successful") + ] = False, ): if exclude: Configuration.excludes.extend(exclude) @@ -42,34 +45,53 @@ def check( @cli.command(help="Scan a codebase") def scan( - path: Annotated[ - Path, typer.Argument(exists=True, file_okay=False, help="Codebase root") - ] = Path("."), - exclude: Annotated[ - Optional[list[str]], typer.Option(help="Glob patterns for exclusion") - ] = None, + path: Annotated[ + Path, typer.Argument(exists=True, file_okay=False, help="Codebase root") + ] = Path("."), + exclude: Annotated[ + Optional[list[str]], typer.Option(help="Glob patterns for exclusion") + ] = None, ): if exclude: Configuration.excludes.extend(exclude) Configuration.load(path) + configure_github_repository(path) scan_command(path) @cli.command(help="Show report for codebase") def report( - path: Annotated[ - Path, typer.Argument(exists=True, file_okay=False, help="Codebase root") - ] = Path("."), - full: Annotated[bool, typer.Option("--full", help="Show full report")] = False, - totals: Annotated[bool, typer.Option("--totals", help="Only show totals")] = False, - fmt: Annotated[ - ReportFormat, typer.Option("--format", help="Output format") - ] = ReportFormat.text, + path: Annotated[ + Path, typer.Argument(exists=True, file_okay=False, help="Codebase root") + ] = Path("."), + full: Annotated[bool, typer.Option("--full", help="Show full report")] = False, + totals: Annotated[bool, typer.Option("--totals", help="Only show totals")] = False, + fmt: Annotated[ + ReportFormat, typer.Option("--format", help="Output format") + ] = ReportFormat.text, ): Configuration.load(path) report_command(path, full, totals, fmt) +@cli.command(help="Generate badge Markdown") +def badge( + path: Annotated[ + Path, typer.Argument(exists=True, file_okay=False, help="Codebase root") + ] = Path(".") +): + Configuration.load(path) + configure_github_repository(path) + owner = Configuration.repository.owner + name = Configuration.repository.name + branch = Configuration.repository.branch + badge_markdown = (f'[![CodeLimit](https://github.com/{owner}/{name}/blob/_codelimit_reports/{branch}/badge.svg)](' + f'https://github.com/{owner}/{name}/blob/_codelimit_reports/{branch}/codelimit.md))') + print(f'{badge_markdown}\n') + pyperclip.copy(badge_markdown) + success("Badge Markdown copied to clipboard!") + + def _version_callback(show: bool): if show: print(f"Code Limit version: {version}") @@ -78,15 +100,15 @@ def _version_callback(show: bool): @cli.callback() def main( - verbose: Annotated[ - Optional[bool], typer.Option("--verbose", "-v", help="Verbose output") - ] = False, - version: Annotated[ - Optional[bool], - typer.Option( - "--version", "-V", help="Show version", callback=_version_callback - ), - ] = None, + verbose: Annotated[ + Optional[bool], typer.Option("--verbose", "-v", help="Verbose output") + ] = False, + version: Annotated[ + Optional[bool], + typer.Option( + "--version", "-V", help="Show version", callback=_version_callback + ), + ] = None, ): """Code Limit: Your refactoring alarm.""" diff --git a/codelimit/commands/report.py b/codelimit/commands/report.py index 7542082..ea98a4c 100644 --- a/codelimit/commands/report.py +++ b/codelimit/commands/report.py @@ -125,7 +125,7 @@ def _report_functions_markdown( result += "| --- | ---: | ---: | ---: | --- |\n" for unit in report_units: file_path = unit.file if root is None else root.joinpath(unit.file) - type = "✖" if unit.measurement.value > 60 else "⚠" + type = "\u274C" if unit.measurement.value > 60 else "\u26A0" result += ( f"| {str(file_path)} | {unit.measurement.start.line} | {unit.measurement.start.column} | " f"{unit.measurement.value} | {type} {unit.measurement.unit_name} |\n" diff --git a/codelimit/common/Configuration.py b/codelimit/common/Configuration.py index 6d8d287..ee9fedb 100644 --- a/codelimit/common/Configuration.py +++ b/codelimit/common/Configuration.py @@ -2,10 +2,13 @@ from yaml import load, FullLoader +from codelimit.common.GithubRepository import GithubRepository + class Configuration: excludes: list[str] = [] verbose = False + repository: GithubRepository | None = None @classmethod def load(cls, root: Path): diff --git a/codelimit/common/GithubRepository.py b/codelimit/common/GithubRepository.py new file mode 100644 index 0000000..fd21423 --- /dev/null +++ b/codelimit/common/GithubRepository.py @@ -0,0 +1,15 @@ +from dataclasses import dataclass + + +@dataclass +class GithubRepository: + owner: str + name: str + branch: str | None = None + tag: str | None = None + + def __str__(self) -> str: + result = f'{self.owner}/{self.name}' + if self.tag: + result += f'@{self.tag}' + return result diff --git a/codelimit/common/console.py b/codelimit/common/console.py new file mode 100644 index 0000000..a9463af --- /dev/null +++ b/codelimit/common/console.py @@ -0,0 +1,3 @@ +from rich.console import Console + +console = Console() diff --git a/codelimit/common/utils.py b/codelimit/common/utils.py index 44d39ab..cfbb47d 100644 --- a/codelimit/common/utils.py +++ b/codelimit/common/utils.py @@ -2,12 +2,16 @@ import os import sys from math import ceil +from pathlib import Path from typing import Union, Any from rich.style import Style from rich.text import Text +from sh import git, ErrorReturnCode +from codelimit.common.Configuration import Configuration from codelimit.common.Measurement import Measurement +from codelimit.common.GithubRepository import GithubRepository from codelimit.common.gsm.Expression import Expression from codelimit.common.gsm.operator.Operator import Operator from codelimit.common.token_matching.predicate.TokenValue import TokenValue @@ -66,7 +70,7 @@ def render_quality_profile(profile: list[int]) -> Text: def path_has_extension(path: str, suffixes: Union[str, list[str]]): dot_index = path.rfind(".") if dot_index >= 0: - suffix = path[dot_index + 1 :] + suffix = path[dot_index + 1:] if isinstance(suffixes, list): return suffix in suffixes else: @@ -199,3 +203,30 @@ def replace_string_literal_with_predicate(expression: Expression) -> Expression: ) ) ] + + +def _get_git_branch(path: Path) -> str | None: + try: + out = git('rev-parse', '--abbrev-ref', 'HEAD', _cwd=path) + return out.strip() + except ErrorReturnCode: + return None + + +def _get_remote_url(path: Path) -> str | None: + try: + out = git('config', '--get', 'remote.origin.url', _cwd=path) + return out.strip() + except ErrorReturnCode: + return None + + +def configure_github_repository(path: Path): + branch = _get_git_branch(path) + url = _get_remote_url(path) + if url.startswith('git@github.com:') and url.endswith('.git'): + [owner, name] = url[15:-4].split('/') + Configuration.repository = GithubRepository(owner, name, branch=branch) + elif url.startswith('https://github.com/') and url.endswith('.git'): + [owner, name] = url[19:-4].split('/') + Configuration.repository = GithubRepository(owner, name, branch=branch) diff --git a/codelimit/utils.py b/codelimit/utils.py index f399841..dfe63e9 100644 --- a/codelimit/utils.py +++ b/codelimit/utils.py @@ -5,11 +5,24 @@ import typer from rich.progress import Progress, SpinnerColumn, TextColumn +from codelimit.common.console import console from codelimit.common.report.Report import Report from codelimit.common.report.ReportReader import ReportReader from codelimit.common.report.ReportWriter import ReportWriter +def info(text: str): + console.print(f'[bold]ℹ︎[/bold] {text}', soft_wrap=True) + + +def success(text: str): + console.print(f'[green]✔[/green] {text}', soft_wrap=True) + + +def fail(text: str): + console.print(f'[red]⨯[/red] {text}', soft_wrap=True) + + def make_report_path(root: Path) -> Path: return root.joinpath(".codelimit_cache").resolve().joinpath("codelimit.json") @@ -24,7 +37,7 @@ def read_cached_report(path: Path) -> Optional[Report]: def upload_report( - report: Report, repository: str, branch: str, url: str, token: str + report: Report, repository: str, branch: str, url: str, token: str ) -> None: result = api_post_report(report, branch, repository, url, token) if result.ok: @@ -44,9 +57,9 @@ def api_post_report(report, branch, repository, url, token): f'{{{{"repository": "{repository}", "branch": "{branch}", "report":{{}}}}}}' ) with Progress( - SpinnerColumn(), - TextColumn("[progress.description]{task.description}"), - transient=True, + SpinnerColumn(), + TextColumn("[progress.description]{task.description}"), + transient=True, ) as progress: progress.add_task(description=f"Uploading report to {url}", total=None) result = requests.post( diff --git a/poetry.lock b/poetry.lock index a815ac9..faf1d87 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1041,6 +1041,16 @@ files = [ packaging = ">=22.0" setuptools = ">=42.0.0" +[[package]] +name = "pyperclip" +version = "1.9.0" +description = "A cross-platform clipboard module for Python. (Only handles plain text for now.)" +optional = false +python-versions = "*" +files = [ + {file = "pyperclip-1.9.0.tar.gz", hash = "sha256:b7de0142ddc81bfc5c7507eea19da920b92252b548b96186caf94a5e2527d310"}, +] + [[package]] name = "pytest" version = "7.4.4" @@ -1452,4 +1462,4 @@ propcache = ">=0.2.0" [metadata] lock-version = "2.0" python-versions = ">=3.10,<3.14" -content-hash = "dd9302e0b76afeecdbe93c7c7ae5d325b5fb895c9d618c3788c3cfe5cbb1a02a" +content-hash = "8a582ca9bf64666ac1384a37acb13424d3d5e674e863775ad2baee917cc4b0a5" diff --git a/pyproject.toml b/pyproject.toml index 409e80c..c6123ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,7 @@ aiohttp = "^3.9.0" pyyaml = "^6.0.1" rich = "^13.7.1" pathspec = "^0.12.1" +pyperclip = "^1.9.0" [tool.pytest.ini_options] addopts = "--tb=short" diff --git a/tests/regression.py b/tests/regression.py index 84fcc3c..6b606c1 100755 --- a/tests/regression.py +++ b/tests/regression.py @@ -6,29 +6,17 @@ import tempfile from pathlib import Path -from rich.console import Console from sh import git +from codelimit.common.GithubRepository import GithubRepository from codelimit.common.ScanResultTable import ScanResultTable from codelimit.common.ScanTotals import ScanTotals from codelimit.common.Scanner import scan_path +from codelimit.common.console import console from codelimit.common.report.Report import Report from codelimit.common.report.ReportReader import ReportReader from codelimit.common.report.ReportWriter import ReportWriter - -console = Console() - - -def info(text: str): - console.print(f'[bold]ℹ︎[/bold] {text}', soft_wrap=True) - - -def success(text: str): - console.print(f'[green]✔[/green] {text}', soft_wrap=True) - - -def fail(text: str): - console.print(f'[red]⨯[/red] {text}', soft_wrap=True) +from codelimit.utils import info, success, fail def load_report(path: Path) -> Report | None: @@ -46,14 +34,14 @@ def save_report(path: Path, report: Report) -> Path: return report_file -def scan_repo(owner: str, name: str, tag: str) -> Report: +def scan_repo(repo: GithubRepository) -> Report: tmp_dir = tempfile.mkdtemp() os.chdir(tmp_dir) info('Cloning repository...') - git('clone', '--depth', '1', '--branch', tag, f'https://github.com/{owner}/{name}.git') + git('clone', '--depth', '1', '--branch', repo.tag, f'https://github.com/{repo.owner}/{repo.name}.git') success('Repository cloned') info('Scanning codebase...') - codebase = scan_path(Path(tmp_dir).joinpath(name)) + codebase = scan_path(Path(tmp_dir).joinpath(repo.name)) success('Codebase scanned') shutil.rmtree(tmp_dir) codebase.aggregate() @@ -77,11 +65,12 @@ def run() -> int: report_dirs = [d for d in examples_dir.iterdir() if d.is_dir()] for report_dir in report_dirs: repo_parts = report_dir.name.split('_') - info(f'Scanning {repo_parts[0]}/{repo_parts[1]}@{repo_parts[2]}') + repo = GithubRepository(repo_parts[0], repo_parts[1], tag=repo_parts[2]) + info(f'Scanning {repo}') old_report = load_report(report_dir) if old_report: success('Existing report loaded') - new_report = scan_repo(repo_parts[0], repo_parts[1], repo_parts[2]) + new_report = scan_repo(repo) if compare_reports(old_report, new_report): success('No changes detected') else: From 68a18a71370d7f7c6f711f96ec46fef90aea2039 Mon Sep 17 00:00:00 2001 From: Rob van der Leek <5324924+robvanderleek@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:10:00 +0100 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20dependencies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codelimit/__main__.py | 6 +++--- codelimit/commands/check.py | 2 +- codelimit/common/Configuration.py | 6 +++--- codelimit/common/Scanner.py | 12 +++++++++--- codelimit/common/utils.py | 2 ++ pyproject.toml | 2 +- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/codelimit/__main__.py b/codelimit/__main__.py index 904db4a..6ecacf7 100755 --- a/codelimit/__main__.py +++ b/codelimit/__main__.py @@ -38,7 +38,7 @@ def check( ] = False, ): if exclude: - Configuration.excludes.extend(exclude) + Configuration.exclude.extend(exclude) Configuration.load(Path('.')) check_command(paths, quiet) @@ -53,7 +53,7 @@ def scan( ] = None, ): if exclude: - Configuration.excludes.extend(exclude) + Configuration.exclude.extend(exclude) Configuration.load(path) configure_github_repository(path) scan_command(path) @@ -86,7 +86,7 @@ def badge( name = Configuration.repository.name branch = Configuration.repository.branch badge_markdown = (f'[![CodeLimit](https://github.com/{owner}/{name}/blob/_codelimit_reports/{branch}/badge.svg)](' - f'https://github.com/{owner}/{name}/blob/_codelimit_reports/{branch}/codelimit.md))') + f'https://github.com/{owner}/{name}/blob/_codelimit_reports/{branch}/codelimit.md)') print(f'{badge_markdown}\n') pyperclip.copy(badge_markdown) success("Badge Markdown copied to clipboard!") diff --git a/codelimit/commands/check.py b/codelimit/commands/check.py index 32a2870..71a7b83 100644 --- a/codelimit/commands/check.py +++ b/codelimit/commands/check.py @@ -15,7 +15,7 @@ def check_command(paths: list[Path], quiet: bool): check_result = CheckResult() - excludes_spec = PathSpec.from_lines("gitignore", Configuration.excludes) + excludes_spec = PathSpec.from_lines("gitignore", Configuration.exclude) for path in paths: if path.is_file(): _handle_file_path(path, check_result, excludes_spec) diff --git a/codelimit/common/Configuration.py b/codelimit/common/Configuration.py index ee9fedb..602563c 100644 --- a/codelimit/common/Configuration.py +++ b/codelimit/common/Configuration.py @@ -6,7 +6,7 @@ class Configuration: - excludes: list[str] = [] + exclude: list[str] = [] verbose = False repository: GithubRepository | None = None @@ -17,7 +17,7 @@ def load(cls, root: Path): return with open(config_path) as f: d = load(f, Loader=FullLoader) - if "excludes" in d: - cls.excludes.extend(d["excludes"]) + if "exclude" in d: + cls.exclude.extend(d["exclude"]) if "verbose" in d: cls.verbose = d["verbose"] diff --git a/codelimit/common/Scanner.py b/codelimit/common/Scanner.py index c6da861..81a4460 100644 --- a/codelimit/common/Scanner.py +++ b/codelimit/common/Scanner.py @@ -136,10 +136,16 @@ def _scan_file( codebase.add_file(entry) return entry +def _read_file(path: Path): + try: + with open(path) as f: + return f.read() + except UnicodeDecodeError: + with open(path, encoding="latin-1") as f: + return f.read() def _analyze_file(path, rel_path, checksum, lexer): - with open(path) as f: - code = f.read() + code = _read_file(path) all_tokens = lex(lexer, code, False) code_tokens = filter_tokens(all_tokens) file_loc = count_lines(code_tokens) @@ -176,7 +182,7 @@ def scan_file(tokens: list[Token], language: Language) -> list[Measurement]: def _generate_exclude_spec(root: Path) -> PathSpec: excludes = DEFAULT_EXCLUDES.copy() - excludes.extend(Configuration.excludes) + excludes.extend(Configuration.exclude) gitignore_excludes = _read_gitignore(root) if gitignore_excludes: excludes.extend(gitignore_excludes) diff --git a/codelimit/common/utils.py b/codelimit/common/utils.py index cfbb47d..e35f11b 100644 --- a/codelimit/common/utils.py +++ b/codelimit/common/utils.py @@ -224,6 +224,8 @@ def _get_remote_url(path: Path) -> str | None: def configure_github_repository(path: Path): branch = _get_git_branch(path) url = _get_remote_url(path) + if not url or not branch: + return if url.startswith('git@github.com:') and url.endswith('.git'): [owner, name] = url[15:-4].split('/') Configuration.repository = GithubRepository(owner, name, branch=branch) diff --git a/pyproject.toml b/pyproject.toml index c6123ca..e286a4b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,7 @@ pyyaml = "^6.0.1" rich = "^13.7.1" pathspec = "^0.12.1" pyperclip = "^1.9.0" +sh = "^2.1.0" [tool.pytest.ini_options] addopts = "--tb=short" @@ -50,7 +51,6 @@ types-pyyaml = "^6.0.12.20240917" mypy = "^1.13.0" black = "^24.10.0" ruff = "^0.8.2" -sh = "^2.1.0" [build-system] requires = ["poetry-core"] From 30547a3b430ed3af5b3a1ff5fee9d5705bd06f36 Mon Sep 17 00:00:00 2001 From: Rob van der Leek <5324924+robvanderleek@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:13:19 +0100 Subject: [PATCH 3/5] =?UTF-8?q?build:=20=E2=AC=86=EF=B8=8F=20Update=20lock?= =?UTF-8?q?=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- poetry.lock | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/poetry.lock b/poetry.lock index faf1d87..98c961e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1206,29 +1206,29 @@ jupyter = ["ipywidgets (>=7.5.1,<9)"] [[package]] name = "ruff" -version = "0.8.2" +version = "0.8.3" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.8.2-py3-none-linux_armv6l.whl", hash = "sha256:c49ab4da37e7c457105aadfd2725e24305ff9bc908487a9bf8d548c6dad8bb3d"}, - {file = "ruff-0.8.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:ec016beb69ac16be416c435828be702ee694c0d722505f9c1f35e1b9c0cc1bf5"}, - {file = "ruff-0.8.2-py3-none-macosx_11_0_arm64.whl", hash = "sha256:f05cdf8d050b30e2ba55c9b09330b51f9f97d36d4673213679b965d25a785f3c"}, - {file = "ruff-0.8.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:60f578c11feb1d3d257b2fb043ddb47501ab4816e7e221fbb0077f0d5d4e7b6f"}, - {file = "ruff-0.8.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:cbd5cf9b0ae8f30eebc7b360171bd50f59ab29d39f06a670b3e4501a36ba5897"}, - {file = "ruff-0.8.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b402ddee3d777683de60ff76da801fa7e5e8a71038f57ee53e903afbcefdaa58"}, - {file = "ruff-0.8.2-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:705832cd7d85605cb7858d8a13d75993c8f3ef1397b0831289109e953d833d29"}, - {file = "ruff-0.8.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:32096b41aaf7a5cc095fa45b4167b890e4c8d3fd217603f3634c92a541de7248"}, - {file = "ruff-0.8.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e769083da9439508833cfc7c23e351e1809e67f47c50248250ce1ac52c21fb93"}, - {file = "ruff-0.8.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5fe716592ae8a376c2673fdfc1f5c0c193a6d0411f90a496863c99cd9e2ae25d"}, - {file = "ruff-0.8.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:81c148825277e737493242b44c5388a300584d73d5774defa9245aaef55448b0"}, - {file = "ruff-0.8.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:d261d7850c8367704874847d95febc698a950bf061c9475d4a8b7689adc4f7fa"}, - {file = "ruff-0.8.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:1ca4e3a87496dc07d2427b7dd7ffa88a1e597c28dad65ae6433ecb9f2e4f022f"}, - {file = "ruff-0.8.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:729850feed82ef2440aa27946ab39c18cb4a8889c1128a6d589ffa028ddcfc22"}, - {file = "ruff-0.8.2-py3-none-win32.whl", hash = "sha256:ac42caaa0411d6a7d9594363294416e0e48fc1279e1b0e948391695db2b3d5b1"}, - {file = "ruff-0.8.2-py3-none-win_amd64.whl", hash = "sha256:2aae99ec70abf43372612a838d97bfe77d45146254568d94926e8ed5bbb409ea"}, - {file = "ruff-0.8.2-py3-none-win_arm64.whl", hash = "sha256:fb88e2a506b70cfbc2de6fae6681c4f944f7dd5f2fe87233a7233d888bad73e8"}, - {file = "ruff-0.8.2.tar.gz", hash = "sha256:b84f4f414dda8ac7f75075c1fa0b905ac0ff25361f42e6d5da681a465e0f78e5"}, + {file = "ruff-0.8.3-py3-none-linux_armv6l.whl", hash = "sha256:8d5d273ffffff0acd3db5bf626d4b131aa5a5ada1276126231c4174543ce20d6"}, + {file = "ruff-0.8.3-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:e4d66a21de39f15c9757d00c50c8cdd20ac84f55684ca56def7891a025d7e939"}, + {file = "ruff-0.8.3-py3-none-macosx_11_0_arm64.whl", hash = "sha256:c356e770811858bd20832af696ff6c7e884701115094f427b64b25093d6d932d"}, + {file = "ruff-0.8.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9c0a60a825e3e177116c84009d5ebaa90cf40dfab56e1358d1df4e29a9a14b13"}, + {file = "ruff-0.8.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:75fb782f4db39501210ac093c79c3de581d306624575eddd7e4e13747e61ba18"}, + {file = "ruff-0.8.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7f26bc76a133ecb09a38b7868737eded6941b70a6d34ef53a4027e83913b6502"}, + {file = "ruff-0.8.3-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:01b14b2f72a37390c1b13477c1c02d53184f728be2f3ffc3ace5b44e9e87b90d"}, + {file = "ruff-0.8.3-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:53babd6e63e31f4e96ec95ea0d962298f9f0d9cc5990a1bbb023a6baf2503a82"}, + {file = "ruff-0.8.3-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1ae441ce4cf925b7f363d33cd6570c51435972d697e3e58928973994e56e1452"}, + {file = "ruff-0.8.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d7c65bc0cadce32255e93c57d57ecc2cca23149edd52714c0c5d6fa11ec328cd"}, + {file = "ruff-0.8.3-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:5be450bb18f23f0edc5a4e5585c17a56ba88920d598f04a06bd9fd76d324cb20"}, + {file = "ruff-0.8.3-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:8faeae3827eaa77f5721f09b9472a18c749139c891dbc17f45e72d8f2ca1f8fc"}, + {file = "ruff-0.8.3-py3-none-musllinux_1_2_i686.whl", hash = "sha256:db503486e1cf074b9808403991663e4277f5c664d3fe237ee0d994d1305bb060"}, + {file = "ruff-0.8.3-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:6567be9fb62fbd7a099209257fef4ad2c3153b60579818b31a23c886ed4147ea"}, + {file = "ruff-0.8.3-py3-none-win32.whl", hash = "sha256:19048f2f878f3ee4583fc6cb23fb636e48c2635e30fb2022b3a1cd293402f964"}, + {file = "ruff-0.8.3-py3-none-win_amd64.whl", hash = "sha256:f7df94f57d7418fa7c3ffb650757e0c2b96cf2501a0b192c18e4fb5571dfada9"}, + {file = "ruff-0.8.3-py3-none-win_arm64.whl", hash = "sha256:fe2756edf68ea79707c8d68b78ca9a58ed9af22e430430491ee03e718b5e4936"}, + {file = "ruff-0.8.3.tar.gz", hash = "sha256:5e7558304353b84279042fc584a4f4cb8a07ae79b2bf3da1a7551d960b5626d3"}, ] [[package]] @@ -1462,4 +1462,4 @@ propcache = ">=0.2.0" [metadata] lock-version = "2.0" python-versions = ">=3.10,<3.14" -content-hash = "8a582ca9bf64666ac1384a37acb13424d3d5e674e863775ad2baee917cc4b0a5" +content-hash = "751317a133881887d80a94acad82a7ee4b008b650c008b4a0a9025a664f751c8" From bdd6723eb622a99e7f04d279e7c48e517be25761 Mon Sep 17 00:00:00 2001 From: Rob van der Leek <5324924+robvanderleek@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:47:06 +0100 Subject: [PATCH 4/5] =?UTF-8?q?chore:=20=F0=9F=9A=A8=20Fix=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codelimit/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codelimit/__main__.py b/codelimit/__main__.py index 6ecacf7..ebcb5fa 100755 --- a/codelimit/__main__.py +++ b/codelimit/__main__.py @@ -12,7 +12,7 @@ from codelimit.commands.scan import scan_command from codelimit.common.Configuration import Configuration from codelimit.common.utils import configure_github_repository -from codelimit.utils import success, info +from codelimit.utils import success from codelimit.version import version From 7295a76e67202b1c09006785d50c34ce8c1a4498 Mon Sep 17 00:00:00 2001 From: Rob van der Leek <5324924+robvanderleek@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:51:24 +0100 Subject: [PATCH 5/5] =?UTF-8?q?chore:=20=F0=9F=9A=A8=20Fix=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codelimit/__main__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/codelimit/__main__.py b/codelimit/__main__.py index ebcb5fa..3b7d714 100755 --- a/codelimit/__main__.py +++ b/codelimit/__main__.py @@ -12,7 +12,7 @@ from codelimit.commands.scan import scan_command from codelimit.common.Configuration import Configuration from codelimit.common.utils import configure_github_repository -from codelimit.utils import success +from codelimit.utils import success, fail from codelimit.version import version @@ -82,6 +82,9 @@ def badge( ): Configuration.load(path) configure_github_repository(path) + if not Configuration.repository: + fail("Could not determine repository information.") + raise typer.Exit(1) owner = Configuration.repository.owner name = Configuration.repository.name branch = Configuration.repository.branch