Skip to content

Fix git metadata detection for deploy with bare manifest filename#815

Open
nealrichardson wants to merge 2 commits into
mainfrom
claude-issue-770
Open

Fix git metadata detection for deploy with bare manifest filename#815
nealrichardson wants to merge 2 commits into
mainfrom
claude-issue-770

Conversation

@nealrichardson

Copy link
Copy Markdown
Contributor

Intent

Resolves #770.

rsconnect deploy manifest manifest.json (and other deploy commands given a bare relative filename) failed to attach git metadata to the bundle upload, even inside a git checkout.

Approach

The deploy commands derive the directory to scan for git metadata with dirname(file). For a bare filename like manifest.json, os.path.dirname("manifest.json") returns "". That empty string was passed straight to subprocess.run(..., cwd=""), which raises FileNotFoundError; _run_git_command catches it and returns None, so is_git_repo("") returned False and metadata detection was silently skipped — the "short-circuit" described in the issue.

The fix normalizes an empty cwd to "." at the single choke point (_run_git_command), so it covers every deploy command that derives base_dir via dirname(...), not just deploy manifest.

Type of Change

  • Bug Fix
  • New Feature
  • Breaking Change

Automated Tests

Added two tests in tests/test_git_metadata.py covering the empty-directory-uses-cwd behavior (is_git_repo("") and detect_git_metadata("") from within a git repo). All tests in the file pass; ruff format/check clean.

Checklist

  • I have updated CHANGELOG.md to cover notable changes.

🤖 Generated with Claude Code

dirname("manifest.json") yields "", which subprocess rejects as cwd,
causing git metadata detection to be silently skipped. Fall back to the
current directory in _run_git_command.

Fixes #770

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nealrichardson nealrichardson requested a review from marcosnav July 6, 2026 15:34
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://posit-dev.github.io/rsconnect-python/pr-preview/pr-815/

Built to branch gh-pages at 2026-07-06 20:00 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
7607 6323 83% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
rsconnect/git_metadata.py 96% 🟢
TOTAL 96% 🟢

updated for commit: 4d20a09 by action🐍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: deploy with manifest doesn't pull in git metadata

1 participant