mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-12 16:15:33 +00:00
Fix git commit id in version not being computed from Serena directory
This commit is contained in:
1 parent
4ff2993bc0
commit
dcc49f19f9
3 files changed
+14
-6
No files matched your search
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user