Skip to content

Commit 477bef1

Browse files
feat: skip respository resolve with --skip-upload
Since we are not going to upload the result anyway, we should still be able to perform the run if the API is not available. This allows offline usage during dev or in a very controlled sandbox environment that only outputs profile.
1 parent 7a17aba commit 477bef1

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

src/run_environment/local/provider.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ impl LocalProvider {
5757
.map(|ctx| ctx.root_path.clone())
5858
.unwrap_or_else(|| current_dir.to_string_lossy().to_string());
5959

60-
let resolved = Self::resolve_repository(config, api_client, git_context.as_ref()).await?;
60+
let resolved = if !config.skip_upload {
61+
Self::resolve_repository(config, api_client, git_context.as_ref()).await?
62+
} else {
63+
Self::dummy_resolved_repository(git_context.as_ref())
64+
};
6165

6266
let expected_run_parts_count = config.expected_run_parts_count();
6367

@@ -84,6 +88,21 @@ impl LocalProvider {
8488
})
8589
}
8690

91+
/// Create a dummy resolved repository, resolved offline when --skip-upload is used and we don't need to resolve the actual repository information from the API
92+
fn dummy_resolved_repository(git_context: Option<&GitContext>) -> ResolvedRepository {
93+
let (ref_, head_ref) = git_context
94+
.and_then(|ctx| Self::get_git_ref_info(&ctx.root_path).ok())
95+
.unwrap_or_else(|| (FAKE_COMMIT_REF.to_string(), None));
96+
97+
ResolvedRepository {
98+
provider: RepositoryProvider::GitHub,
99+
owner: "local".to_string(),
100+
name: "local".to_string(),
101+
ref_,
102+
head_ref,
103+
}
104+
}
105+
87106
/// Resolve repository information from override, git remote, or API fallback
88107
async fn resolve_repository(
89108
config: &OrchestratorConfig,

0 commit comments

Comments
 (0)