diff --git a/CHANGELOG.md b/CHANGELOG.md index c3db50aa..44e37a72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,12 @@ Status of the `main` branch. Changes prior to the next official version change will appear here. +* Dashboard: + - Add version display + * Fixes: - Fix reactivation of the same project restarting language servers #1280 + - Fix git commit id in version # 1.0.0 diff --git a/src/serena/util/git.py b/src/serena/util/git.py index 865ae59e..ec88179f 100644 --- a/src/serena/util/git.py +++ b/src/serena/util/git.py @@ -2,6 +2,7 @@ import logging from sensai.util.git import GitStatus +from ..constants import REPO_ROOT from .shell import subprocess_check_output log = logging.getLogger(__name__) @@ -9,10 +10,11 @@ log = logging.getLogger(__name__) def get_git_status() -> GitStatus | None: try: - commit_hash = subprocess_check_output(["git", "rev-parse", "HEAD"]) - unstaged = bool(subprocess_check_output(["git", "diff", "--name-only"])) - staged = bool(subprocess_check_output(["git", "diff", "--staged", "--name-only"])) - untracked = bool(subprocess_check_output(["git", "ls-files", "--others", "--exclude-standard"])) + cwd = REPO_ROOT + commit_hash = subprocess_check_output(["git", "rev-parse", "HEAD"], cwd=cwd) + unstaged = bool(subprocess_check_output(["git", "diff", "--name-only"], cwd=cwd)) + staged = bool(subprocess_check_output(["git", "diff", "--staged", "--name-only"], cwd=cwd)) + untracked = bool(subprocess_check_output(["git", "ls-files", "--others", "--exclude-standard"], cwd=cwd)) return GitStatus( commit=commit_hash, has_unstaged_changes=unstaged, has_staged_uncommitted_changes=staged, has_untracked_files=untracked ) diff --git a/src/serena/util/shell.py b/src/serena/util/shell.py index ce10cdbf..a8fad3b1 100644 --- a/src/serena/util/shell.py +++ b/src/serena/util/shell.py @@ -42,9 +42,11 @@ def execute_shell_command(command: str, cwd: str | None = None, capture_stderr: return ShellCommandResult(stdout=stdout, stderr=stderr, return_code=process.returncode, cwd=cwd) -def subprocess_check_output(args: list[str], encoding: str = "utf-8", strip: bool = True, timeout: float | None = None) -> str: +def subprocess_check_output( + args: list[str], encoding: str = "utf-8", strip: bool = True, timeout: float | None = None, cwd: str | None = None +) -> str: output = subprocess.check_output( - args, stdin=subprocess.DEVNULL, stderr=subprocess.PIPE, timeout=timeout, env=os.environ.copy(), **subprocess_kwargs() + args, stdin=subprocess.DEVNULL, stderr=subprocess.PIPE, timeout=timeout, env=os.environ.copy(), cwd=cwd, **subprocess_kwargs() ).decode(encoding) # type: ignore if strip: output = output.strip()