Skip to content

Commit c0beb47

Browse files
revert: Revert GHA base branch detection (#2776) (#2789)
This reverts commit b259595 from #2776 This change is causing CI to fail on `master`. As I would like to release Sentry CLI, we need to revert this to unblock the release process.
1 parent e53e763 commit c0beb47

File tree

6 files changed

+9
-49
lines changed

6 files changed

+9
-49
lines changed

src/commands/build/upload.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ use crate::utils::fs::TempDir;
2424
use crate::utils::fs::TempFile;
2525
use crate::utils::progress::ProgressBar;
2626
use crate::utils::vcs::{
27-
self, get_github_base_ref, get_github_pr_number, get_provider_from_remote,
28-
get_repo_from_remote_preserve_case, git_repo_base_ref, git_repo_base_repo_name_preserve_case,
29-
git_repo_head_ref, git_repo_remote_url,
27+
self, get_github_pr_number, get_provider_from_remote, get_repo_from_remote_preserve_case,
28+
git_repo_base_ref, git_repo_base_repo_name_preserve_case, git_repo_head_ref,
29+
git_repo_remote_url,
3030
};
3131

3232
pub fn make_command(command: Command) -> Command {
@@ -176,11 +176,8 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
176176
.map(String::as_str)
177177
.map(Cow::Borrowed)
178178
.or_else(|| {
179-
// First try GitHub Actions environment variables
180-
get_github_base_ref().map(Cow::Owned)
181-
})
182-
.or_else(|| {
183-
// Fallback to git repository introspection
179+
// Try to get the base ref from the VCS if not provided
180+
// This attempts to find the merge-base with the remote tracking branch
184181
repo_ref
185182
.and_then(|r| match git_repo_base_ref(r, &cached_remote) {
186183
Ok(base_ref_name) => {

src/utils/vcs.rs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -359,21 +359,6 @@ pub fn get_github_pr_number() -> Option<u32> {
359359
Some(pr_number)
360360
}
361361

362-
/// Attempts to get the base branch from GitHub Actions environment variables.
363-
/// Returns the base branch name if running in a GitHub Actions pull request environment.
364-
pub fn get_github_base_ref() -> Option<String> {
365-
let event_name = std::env::var("GITHUB_EVENT_NAME").ok()?;
366-
367-
if event_name != "pull_request" {
368-
debug!("Not running in pull_request event, got: {}", event_name);
369-
return None;
370-
}
371-
372-
let base_ref = std::env::var("GITHUB_BASE_REF").ok()?;
373-
debug!("Auto-detected base ref from GitHub Actions: {}", base_ref);
374-
Some(base_ref)
375-
}
376-
377362
fn find_reference_url(repo: &str, repos: &[Repo]) -> Result<Option<String>> {
378363
let mut non_git = false;
379364
for configured_repo in repos {
@@ -1481,30 +1466,4 @@ mod tests {
14811466
std::env::remove_var("GITHUB_EVENT_NAME");
14821467
std::env::remove_var("GITHUB_REF");
14831468
}
1484-
1485-
#[test]
1486-
fn test_get_github_base_ref() {
1487-
std::env::set_var("GITHUB_EVENT_NAME", "pull_request");
1488-
std::env::set_var("GITHUB_BASE_REF", "main");
1489-
let base_ref = get_github_base_ref();
1490-
assert_eq!(base_ref, Some("main".to_owned()));
1491-
1492-
// Test with different base branch
1493-
std::env::set_var("GITHUB_BASE_REF", "develop");
1494-
let base_ref = get_github_base_ref();
1495-
assert_eq!(base_ref, Some("develop".to_owned()));
1496-
1497-
// Test when not in pull_request event
1498-
std::env::set_var("GITHUB_EVENT_NAME", "push");
1499-
let base_ref = get_github_base_ref();
1500-
assert_eq!(base_ref, None);
1501-
1502-
// Test when GITHUB_BASE_REF is not set
1503-
std::env::set_var("GITHUB_EVENT_NAME", "pull_request");
1504-
std::env::remove_var("GITHUB_BASE_REF");
1505-
let base_ref = get_github_base_ref();
1506-
assert_eq!(base_ref, None);
1507-
1508-
std::env::remove_var("GITHUB_EVENT_NAME");
1509-
}
15101469
}

tests/integration/_cases/build/build-upload-apk-all-uploaded.trycmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
$ sentry-cli build upload tests/integration/_fixtures/build/apk.apk
33
? success
44
[..]WARN[..]EXPERIMENTAL: The build subcommand is experimental. The command is subject to breaking changes and may be removed without notice in any release.
5+
WARN [..] Could not detect base branch reference: [..]
56
Successfully uploaded 1 file to Sentry
67
- tests/integration/_fixtures/build/apk.apk (http[..]/wat-org/preprod/wat-project/42)
78

tests/integration/_cases/build/build-upload-apk-no-token.trycmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
$ sentry-cli build upload tests/integration/_fixtures/build/apk.apk
33
? failed
44
[..]WARN[..]EXPERIMENTAL: The build subcommand is experimental. The command is subject to breaking changes and may be removed without notice in any release.
5+
WARN [..] Could not detect base branch reference: [..]
56
error: Auth token is required for this request. Please run `sentry-cli login` and try again!
67

78
Add --log-level=[info|debug] or export SENTRY_LOG_LEVEL=[info|debug] to see more output.

tests/integration/_cases/build/build-upload-apk.trycmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
$ sentry-cli build upload tests/integration/_fixtures/build/apk.apk --head-sha test_head_sha
33
? success
44
[..]WARN[..]EXPERIMENTAL: The build subcommand is experimental. The command is subject to breaking changes and may be removed without notice in any release.
5+
WARN [..] Could not detect base branch reference: [..]
56
Successfully uploaded 1 file to Sentry
67
- tests/integration/_fixtures/build/apk.apk (http[..]/wat-org/preprod/wat-project/42)
78

tests/integration/_cases/build/build-upload-ipa.trycmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
$ sentry-cli build upload tests/integration/_fixtures/build/ipa.ipa --head-sha test_head_sha
33
? success
44
[..]WARN[..]EXPERIMENTAL: The build subcommand is experimental. The command is subject to breaking changes and may be removed without notice in any release.
5+
WARN [..] Could not detect base branch reference: [..]
56
Successfully uploaded 1 file to Sentry
67
- tests/integration/_fixtures/build/ipa.ipa (http[..]/wat-org/preprod/wat-project/some-text-id)
78

0 commit comments

Comments
 (0)