-
Notifications
You must be signed in to change notification settings - Fork 7k
fix: silence git fetch stdout to prevent branch number parse error #1696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,134 @@ | ||||
| """ | ||||
| Tests for scripts/bash/create-new-feature.sh. | ||||
|
|
||||
| Tests cover: | ||||
| - JSON output validity when git fetch produces stdout noise (#1592) | ||||
| - Correct stdout/stderr suppression in check_existing_branches() | ||||
| """ | ||||
|
|
||||
| import json | ||||
| import shutil | ||||
| import subprocess | ||||
| from pathlib import Path | ||||
|
|
||||
| import pytest | ||||
|
|
||||
| SCRIPT_PATH = Path(__file__).resolve().parent.parent / "scripts" / "bash" / "create-new-feature.sh" | ||||
|
|
||||
| requires_git = pytest.mark.skipif( | ||||
| shutil.which("git") is None, | ||||
| reason="git is not installed", | ||||
| ) | ||||
|
|
||||
|
|
||||
| @pytest.fixture | ||||
| def git_repo(tmp_path): | ||||
| """Create a temporary git repo with a fake remote that produces stdout on fetch.""" | ||||
| repo = tmp_path / "repo" | ||||
| repo.mkdir() | ||||
|
|
||||
| # Initialize git repo | ||||
| subprocess.run(["git", "init", str(repo)], capture_output=True, check=True) | ||||
| subprocess.run(["git", "-C", str(repo), "config", "user.email", "test@test.com"], capture_output=True, check=True) | ||||
| subprocess.run(["git", "-C", str(repo), "config", "user.name", "Test"], capture_output=True, check=True) | ||||
|
|
||||
| # Create an initial commit so HEAD exists | ||||
| (repo / "README.md").write_text("# Test") | ||||
| subprocess.run(["git", "-C", str(repo), "add", "."], capture_output=True, check=True) | ||||
| subprocess.run(["git", "-C", str(repo), "commit", "-m", "init"], capture_output=True, check=True) | ||||
|
|
||||
|
Comment on lines
+35
to
+40
|
||||
| # Create .specify dir to simulate an initialized project | ||||
| (repo / ".specify").mkdir() | ||||
| (repo / ".specify" / "templates").mkdir() | ||||
|
|
||||
| yield repo | ||||
| shutil.rmtree(tmp_path) | ||||
|
||||
| shutil.rmtree(tmp_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
git_repofixture docstring says it creates “a fake remote that produces stdout on fetch”, but the fixture never configures any remotes. Either update the docstring to match what the fixture actually does, or add a local/bare remote setup so the test genuinely exercises the fetch-output scenario described in #1592.This issue also appears in the following locations of the same file: