Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- Fixed a bug where `rsconnect deploy manifest manifest.json` (and other deploy
commands given a bare filename) failed to detect git metadata. The directory
passed to git detection was empty in that case, which caused detection to be
silently skipped; it now falls back to the current directory.
- The `CONNECT_SERVER_VERSION` environment variable can now be set to tell
rsconnect-python which Connect version to assume for feature-availability
checks. Some servers can be configured to suppress their version, which makes
Expand Down
4 changes: 3 additions & 1 deletion rsconnect/git_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def _run_git_command(args: list[str], cwd: str) -> Optional[str]:
try:
result = subprocess.run(
["git"] + args,
cwd=cwd,
# dirname() of a bare filename (e.g. "manifest.json") yields "",
# which subprocess rejects; treat it as the current directory.
cwd=cwd or ".",
capture_output=True,
text=True,
timeout=5,
Expand Down
13 changes: 13 additions & 0 deletions tests/test_git_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ def test_detect_git_metadata_non_git_dir(self):
metadata = detect_git_metadata(tmpdir)
assert metadata == {}

def test_is_git_repo_empty_dir_uses_cwd(self, git_repo, monkeypatch):
# dirname("manifest.json") yields "", which subprocess rejects as cwd.
# An empty directory should be treated as the current directory so that
# `rsconnect deploy manifest manifest.json` still detects git metadata.
monkeypatch.chdir(git_repo)
assert is_git_repo("") is True

def test_detect_git_metadata_empty_dir_uses_cwd(self, git_repo, monkeypatch):
monkeypatch.chdir(git_repo)
metadata = detect_git_metadata("")
assert metadata["source"] == "git"
assert metadata["source_repo"] == "https://github.com/user/repo.git"


class TestServerVersionSupport:
def test_server_supports_git_metadata(self):
Expand Down
Loading