Skip to content

Commit 5bd069d

Browse files
committed
Fix failed tests
1 parent c3657de commit 5bd069d

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

src/specfact_cli/adapters/ado.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,6 +1806,19 @@ def _verify_branch_exists(self, branch_name: str, repo_path: Path) -> bool:
18061806
try:
18071807
import subprocess
18081808

1809+
# Use git show-ref for more reliable branch checking
1810+
result = subprocess.run(
1811+
["git", "show-ref", "--verify", "--quiet", f"refs/heads/{branch_name}"],
1812+
cwd=repo_path,
1813+
capture_output=True,
1814+
text=True,
1815+
timeout=5,
1816+
check=False,
1817+
)
1818+
if result.returncode == 0:
1819+
return True
1820+
1821+
# Fallback: check using git branch --list (for compatibility)
18091822
result = subprocess.run(
18101823
["git", "branch", "--list", branch_name],
18111824
cwd=repo_path,
@@ -1815,8 +1828,17 @@ def _verify_branch_exists(self, branch_name: str, repo_path: Path) -> bool:
18151828
check=False,
18161829
)
18171830
# Check if branch exists locally
1818-
if result.returncode == 0:
1819-
branches = [line.strip().replace("*", "").strip() for line in result.stdout.split("\n") if line.strip()]
1831+
if result.returncode == 0 and result.stdout.strip():
1832+
# Parse branch names from output (handles both "* branch" and " branch" formats)
1833+
branches = []
1834+
for line in result.stdout.split("\n"):
1835+
line = line.strip()
1836+
if line:
1837+
# Remove asterisk and any leading/trailing whitespace
1838+
branch = line.replace("*", "").strip()
1839+
if branch:
1840+
branches.append(branch)
1841+
# Check if exact branch name matches (after normalization)
18201842
if branch_name in branches:
18211843
return True
18221844

@@ -1829,7 +1851,7 @@ def _verify_branch_exists(self, branch_name: str, repo_path: Path) -> bool:
18291851
timeout=5,
18301852
check=False,
18311853
)
1832-
if result.returncode == 0:
1854+
if result.returncode == 0 and result.stdout.strip():
18331855
# Extract branch name from remote branch format
18341856
remote_branches = []
18351857
for line in result.stdout.split("\n"):

src/specfact_cli/adapters/backlog_base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ def create_source_tracking(
135135
else:
136136
source_id = item_data.get("id") or item_data.get("number")
137137
if source_id is not None:
138-
source_metadata["source_id"] = source_id
138+
# Convert to string for consistency (backlog IDs are typically strings)
139+
source_metadata["source_id"] = str(source_id)
139140
# Prefer html_url (user-friendly) over url (API URL)
140141
if "html_url" in item_data:
141142
source_metadata["source_url"] = item_data.get("html_url")

0 commit comments

Comments
 (0)