Skip to content

Commit d320c06

Browse files
committed
Cleanup based on feedback
1 parent 5c19bf7 commit d320c06

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/commands/mobile_app/upload.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ use crate::utils::mobile_app::{
2323
};
2424
use crate::utils::mobile_app::{is_aab_file, is_apk_file, is_zip_file, normalize_directory};
2525
use crate::utils::progress::ProgressBar;
26-
use crate::utils::vcs::{self, get_provider_from_remote, get_repo_from_remote};
26+
use crate::utils::vcs::{
27+
self, get_provider_from_remote, get_repo_from_remote, git_repo_remote_url,
28+
};
2729

2830
pub fn make_command(command: Command) -> Command {
2931
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
@@ -107,20 +109,8 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
107109
// Try to open the git repository and find the remote, but handle errors gracefully.
108110
let (vcs_provider, head_repo_name) = {
109111
// Try to open the repo and get the remote URL, but don't fail if not in a repo.
110-
let remote_url = match git2::Repository::open_from_env().and_then(|repo| {
111-
repo.find_remote(&cached_remote).and_then(|remote| {
112-
remote
113-
.url()
114-
.map(|url| url.to_owned())
115-
.ok_or_else(|| git2::Error::from_str("No remote URL found"))
116-
})
117-
}) {
118-
Ok(url) => Some(url),
119-
Err(err) => {
120-
debug!("Could not determine git remote: {err}");
121-
None
122-
}
123-
};
112+
let repo = git2::Repository::open_from_env().ok();
113+
let remote_url = repo.and_then(|repo| git_repo_remote_url(&repo, &cached_remote).ok());
124114

125115
let vcs_provider: Option<Cow<'_, str>> = matches
126116
.get_one("vcs_provider")

src/utils/vcs.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,15 @@ pub fn get_provider_from_remote(remote: &str) -> String {
222222
obj.provider
223223
}
224224

225+
#[cfg(feature = "unstable-mobile-app")]
226+
pub fn git_repo_remote_url(repo: &git2::Repository, cached_remote: &str) -> Result<String, git2::Error> {
227+
let remote = repo.find_remote(cached_remote)?;
228+
remote
229+
.url()
230+
.map(|url| url.to_owned())
231+
.ok_or_else(|| git2::Error::from_str("No remote URL found"))
232+
}
233+
225234
fn find_reference_url(repo: &str, repos: &[Repo]) -> Result<Option<String>> {
226235
let mut non_git = false;
227236
for configured_repo in repos {

0 commit comments

Comments
 (0)