feat(build): Add auto-detection of base_repo_name from git remote#2735
Conversation
Automatically detect base_repo_name for build uploads when not explicitly provided. The implementation fetches the first available git remote and extracts the repository name, following the same pattern as existing VCS auto-detection features. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
szokeasaurusrex
left a comment
There was a problem hiding this comment.
Looks good, just one question about picking the branch.
Also, another design question: does it really make sense to fall back to the first branch if origin is missing? I think it is sensible if there is only one remote configured, but if there are multiple remotes, and none of them are origin, it might instead be a good idea to not set a remote and instead print a warning.
Although, as this is likely an edge case, I think it is also ok to stick with the current implementation, just wanted to ask whether you considered this already :)
| return Ok(None); | ||
| } | ||
|
|
||
| // Prefer "origin" remote if it exists, otherwise use the first one |
There was a problem hiding this comment.
Should we also consider checking the upstream remote of the current branch? If so, would that take precedence over origin or not?
There was a problem hiding this comment.
This is a good point. I checked back with our team. We should prefer upstream over origin for forked workflows. I'll update this in a separate PR.
|
That's a good question about falling back to the first branch in the list if there is no origin.
Either way, the outcome is the same the integration doesn't work. Guessing using the first one in the list might be right some of the time so it is better to do that than to return nothing. If the integration doesn't work (either if we returned nothing or guessed wrong) the user will need to override the value. So we'll stick with the current implementation of guessing the first one in the list. |
Summary
Implements EME-232 to automatically detect
base_repo_namefor build uploads when not explicitly provided by the user.Changes
git_repo_base_repo_name()function insrc/utils/vcs.rsthat:get_repo_from_remote()function🤖 Generated with Claude Code
Closes https://linear.app/getsentry/issue/EME-232/sentry-cli-provide-default-value-for-base-repo-name-if-user-doesnt