From b614d29e505e43a425f202a67fa6c66473663377 Mon Sep 17 00:00:00 2001 From: Serhii Tereshchenko Date: Tue, 29 Oct 2024 23:58:09 +0200 Subject: [PATCH] draft: Add an option to limit maximum commits used for frecency Refs #711 --- docs/configuration.md | 3 +++ seagoat/repository.py | 3 +++ seagoat/utils/config.py | 2 ++ 3 files changed, 8 insertions(+) diff --git a/docs/configuration.md b/docs/configuration.md index 58ce2aad..c3ef3d85 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -25,6 +25,9 @@ This is an example of a configuration file: server: port: 31134 # A port number to run the server on + # Increase number of commits used for computing frecency score + # Default is `1000`, set to `null` to read all history + readMaxCommits: 5000 # globs to ignore in addition to .gitignore ignorePatterns: diff --git a/seagoat/repository.py b/seagoat/repository.py index 848e8cb0..d21662ba 100644 --- a/seagoat/repository.py +++ b/seagoat/repository.py @@ -92,6 +92,9 @@ def analyze_files(self): "--no-merges", ] + if (max_commits := self.config["server"]["readMaxCommits"]) is not None: + cmd.append(f"--max-count={max_commits}") + self.file_changes.clear() files = set( diff --git a/seagoat/utils/config.py b/seagoat/utils/config.py index 6f718144..be447386 100644 --- a/seagoat/utils/config.py +++ b/seagoat/utils/config.py @@ -13,6 +13,7 @@ "server": { "port": None, "ignorePatterns": [], + "readMaxCommits": 1000, "chroma": { "embeddingFunction": { "name": "DefaultEmbeddingFunction", @@ -35,6 +36,7 @@ "additionalProperties": False, "properties": { "port": {"type": "integer", "minimum": 1, "maximum": 65535}, + "readMaxCommits": {"type": ["integer", "null"], "minimum": 1, "maximum": 65535}, "ignorePatterns": { "type": "array", "items": {"type": "string"},