Skip to content

Commit 8505a31

Browse files
runningcodeclaudeszokeasaurusrex
authored
feat(build): Add --force-git-metadata flag with CI auto-detection (EME-604) (#2974)
## Summary - Adds `--force-git-metadata` and `--no-git-metadata` flags to control git metadata collection for build uploads - Implements CI detection that automatically enables git metadata only when running in most CI environments (GitHub Actions, GitLab CI, Jenkins, etc.) - Prevents local dev builds from triggering unwanted GitHub status checks while maintaining automatic behavior for CI builds - Refactors git metadata handling to use `VcsInfo` directly, eliminating duplicate `GitMetadata` struct ## Changes **New CI Detection Module** (`src/utils/ci.rs`): - Checks common CI environment variables to determine if running in CI - Based on logic from sentry-android-gradle-plugin **Build Upload Command** (`src/commands/build/upload.rs`): - Added two separate boolean flags for clarity: - `--force-git-metadata` - Force enable git metadata collection - `--no-git-metadata` - Force disable git metadata collection - Default (no flag) - Auto-detect CI environment - Refactored to use `VcsInfo` struct directly instead of intermediate `GitMetadata` struct - Simplified string handling in `collect_git_metadata` function Fixes EME-604 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Daniel Szoke <7881302+szokeasaurusrex@users.noreply.github.com>
1 parent 0387052 commit 8505a31

File tree

7 files changed

+347
-177
lines changed

7 files changed

+347
-177
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
## Unreleased
44

55
### Improvements
6-
6+
- For the `sentry-cli build upload` command, we now only auto-detect Git metadata when we detect we are running in a CI environment, unless the user manually overrides this behavior ([#2974](https://github.com/getsentry/sentry-cli/pull/2974)). This change prevents local development builds from triggiering GitHub status checks for size analysis.
7+
- We can detect most common CI environments based on the environment variables these set.
8+
- We introduced two new arguments, `--force-git-metadata` and `--no-git-metadata`, which force-enable and force-disable automatic Git data collection, respectively, overriding the default behavior.
79
- The `sentry-cli build upload` command now automatically detects the correct branch or tag reference in non-PR GitHub Actions workflows ([#2976](https://github.com/getsentry/sentry-cli/pull/2976)). Previously, `--head-ref` was only auto-detected for pull request workflows. Now it works for push, release, and other workflow types by using the `GITHUB_REF_NAME` environment variable.
810

911
## 2.58.2

src/api/data_types/chunking/build.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::borrow::Cow;
2+
13
use serde::{Deserialize, Serialize};
24
use sha1_smol::Digest;
35

@@ -32,15 +34,15 @@ pub struct VcsInfo<'a> {
3234
#[serde(skip_serializing_if = "Option::is_none")]
3335
pub base_sha: Option<Digest>,
3436
#[serde(skip_serializing_if = "str::is_empty", rename = "provider")]
35-
pub vcs_provider: &'a str,
37+
pub vcs_provider: Cow<'a, str>,
3638
#[serde(skip_serializing_if = "str::is_empty")]
37-
pub head_repo_name: &'a str,
39+
pub head_repo_name: Cow<'a, str>,
3840
#[serde(skip_serializing_if = "str::is_empty")]
39-
pub base_repo_name: &'a str,
41+
pub base_repo_name: Cow<'a, str>,
4042
#[serde(skip_serializing_if = "str::is_empty")]
41-
pub head_ref: &'a str,
43+
pub head_ref: Cow<'a, str>,
4244
#[serde(skip_serializing_if = "str::is_empty")]
43-
pub base_ref: &'a str,
45+
pub base_ref: Cow<'a, str>,
4446
#[serde(skip_serializing_if = "Option::is_none")]
4547
pub pr_number: Option<u32>,
4648
}

0 commit comments

Comments
 (0)