@comate/zulu 1.5.0 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,6 +43,22 @@ def _get_current_branch(workspace):
43
43
  return ""
44
44
 
45
45
 
46
+ def _get_upstream_branch(workspace):
47
+ """获取当前分支的上游远端分支名(strip remote 前缀)"""
48
+ try:
49
+ result = subprocess.run(
50
+ ["git", "rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{upstream}"],
51
+ capture_output=True, text=True, encoding="utf-8", errors="replace",
52
+ timeout=10, cwd=workspace
53
+ )
54
+ if result.returncode == 0 and result.stdout.strip():
55
+ upstream = result.stdout.strip()
56
+ return upstream.split("/", 1)[-1] if "/" in upstream else upstream
57
+ except (subprocess.TimeoutExpired, FileNotFoundError, OSError):
58
+ pass
59
+ return ""
60
+
61
+
46
62
  def _get_remote_branches(workspace, current_branch):
47
63
  try:
48
64
  result = subprocess.run(
@@ -74,7 +90,9 @@ def _build_workspace_entry(workspace_path, diff_info):
74
90
  repo_name = os.path.basename(workspace_path)
75
91
 
76
92
  if has_changes:
77
- current_branch = _get_current_branch(workspace_path)
93
+ local_branch = _get_current_branch(workspace_path)
94
+ upstream_branch = _get_upstream_branch(workspace_path)
95
+ current_branch = upstream_branch or local_branch
78
96
  remote_branches = _get_remote_branches(workspace_path, current_branch)
79
97
  diff_summary = {
80
98
  "changed_files": diff_info.get("changed_files", []),