Skip to content

Commit 7c79c74

Browse files
committed
Add default vcs head_repo_name and provider parsing for mobile-app subcommand
1 parent 75920e8 commit 7c79c74

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

src/commands/mobile_app/upload.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ 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;
26+
use crate::utils::vcs::{self, get_provider_from_remote, get_repo_from_remote};
2727

2828
pub fn make_command(command: Command) -> Command {
2929
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
@@ -92,6 +92,7 @@ pub fn make_command(command: Command) -> Command {
9292
}
9393

9494
pub fn execute(matches: &ArgMatches) -> Result<()> {
95+
let config = Config::current();
9596
let path_strings = matches
9697
.get_many::<String>("paths")
9798
.expect("paths argument is required");
@@ -103,13 +104,24 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
103104
.or_else(|| vcs::find_head().ok().map(Cow::Owned));
104105

105106
let base_sha = matches.get_one("base_sha").map(String::as_str);
106-
let vcs_provider = matches.get_one("vcs_provider").map(String::as_str);
107-
let head_repo_name = matches.get_one("head_repo_name").map(String::as_str);
108107
let base_repo_name = matches.get_one("base_repo_name").map(String::as_str);
109108
let head_ref = matches.get_one("head_ref").map(String::as_str);
110109
let base_ref = matches.get_one("base_ref").map(String::as_str);
111110
let pr_number = matches.get_one::<u32>("pr_number");
112111

112+
let remote = config.get_cached_vcs_remote();
113+
114+
let vcs_provider = matches
115+
.get_one("vcs_provider")
116+
.map(String::as_str)
117+
.map(Cow::Borrowed)
118+
.or_else(|| Some(Cow::Owned(get_provider_from_remote(&remote))));
119+
let head_repo_name = matches
120+
.get_one("head_repo_name")
121+
.map(String::as_str)
122+
.map(Cow::Borrowed)
123+
.or_else(|| Some(Cow::Owned(get_repo_from_remote(&remote))));
124+
113125
let build_configuration = matches.get_one("build_configuration").map(String::as_str);
114126

115127
let api = Api::current();
@@ -171,8 +183,8 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
171183
let vcs_info = VcsInfo {
172184
head_sha: head_sha.as_deref(),
173185
base_sha,
174-
vcs_provider,
175-
head_repo_name,
186+
vcs_provider: vcs_provider.as_deref(),
187+
head_repo_name: head_repo_name.as_deref(),
176188
base_repo_name,
177189
head_ref,
178190
base_ref,

src/utils/vcs.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ pub fn get_repo_from_remote(repo: &str) -> String {
216216
obj.id
217217
}
218218

219+
pub fn get_provider_from_remote(remote: &str) -> String {
220+
let obj = VcsUrl::parse(remote);
221+
obj.provider
222+
}
223+
219224
fn find_reference_url(repo: &str, repos: &[Repo]) -> Result<Option<String>> {
220225
let mut non_git = false;
221226
for configured_repo in repos {

0 commit comments

Comments
 (0)