Skip to content

Commit 8b900ad

Browse files
committed
Merge branch 'master' into srest2021/REPLAY-413
2 parents 6cc111f + bcdc20b commit 8b900ad

9 files changed

Lines changed: 57 additions & 16 deletions

File tree

.github/workflows/build.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ jobs:
3333
steps:
3434
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 5.0.0
3535

36+
- name: Add Rustup Target
37+
run: |
38+
rustup set profile minimal
39+
rustup target add ${{ matrix.target }}
40+
41+
- name: Cache Dependencies
42+
uses: swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # 2.8.0
43+
3644
- name: Build
3745
run: cargo build --release --target=${{ matrix.target }} --locked
3846

@@ -64,6 +72,9 @@ jobs:
6472
- name: Add Rustup Target
6573
run: rustup target add ${{ matrix.target }}
6674

75+
- name: Cache Dependencies
76+
uses: swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # 2.8.0
77+
6778
- name: Run Cargo Build
6879
run: cargo build --target=${{ matrix.target }} --release --locked
6980

@@ -190,6 +201,9 @@ jobs:
190201
- name: Add Rustup Target
191202
run: rustup target add ${{ env.TARGET }}
192203

204+
- name: Cache Dependencies
205+
uses: swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # 2.8.0
206+
193207
- name: Run Cargo Build
194208
run: cargo build --target=${{ env.TARGET }} --release --locked
195209

.github/workflows/lint.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ jobs:
4040
- name: Checkout Repository
4141
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 5.0.0
4242

43-
- name: Install Rust Toolchain
44-
run: rustup toolchain install stable --profile minimal --component clippy --component rustfmt --no-self-update
45-
46-
- name: Add Target
47-
run: rustup target add ${{ matrix.target }}
43+
- name: Setup Rust Toolchain
44+
run: |
45+
rustup set profile minimal
46+
rustup component add clippy rustfmt
47+
rustup target add ${{ matrix.target }}
4848
4949
- name: Install musl-gcc (Linux only)
5050
if: matrix.os == 'ubuntu-24.04'

.github/workflows/test.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ jobs:
4141
- name: Checkout Repository
4242
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 5.0.0
4343

44-
- name: Add Target
45-
run: rustup target add ${{ matrix.target }}
44+
- name: Setup Rust Toolchain
45+
run: |
46+
rustup set profile minimal
47+
rustup target add ${{ matrix.target }}
4648
4749
- name: Install musl-gcc (Linux only)
4850
if: matrix.os == 'ubuntu-24.04'

CLAUDE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,7 @@ Access the `.cursor/rules/` directory and read rule file contents. Parse the fro
7676
- **Parse frontmatter carefully** - use the metadata to determine rule applicability
7777

7878
Treat these rules as **mandatory guidance** that you must follow for all code changes and development activities within this project.
79+
80+
# Code Formatting
81+
82+
**ALWAYS** run `cargo fmt` before committing any Rust code changes to ensure consistent formatting across the codebase.

rust-toolchain.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[toolchain]
2+
# We pin the minor version to prevent new Clippy lints from breaking CI.
3+
# But, we still want to pick up new patch versions.
4+
channel = "1.89"

src/commands/bash_hook.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ use crate::config::Config;
1919
use crate::utils::event::{attach_logfile, get_sdk_info};
2020
use crate::utils::releases::detect_release_name;
2121

22+
const MAX_BREADCRUMBS: usize = 100;
23+
2224
const BASH_SCRIPT: &str = include_str!("../bashsupport.sh");
2325
lazy_static! {
2426
static ref FRAME_RE: Regex = Regex::new(r"^(.*?):(.*):(\d+)$").unwrap();
@@ -188,7 +190,7 @@ fn send_event(
188190
}
189191
}
190192

191-
attach_logfile(&mut event, logfile, true)?;
193+
attach_logfile(&mut event, logfile, true, MAX_BREADCRUMBS)?;
192194

193195
event.exception.values.push(Exception {
194196
ty: "BashError".into(),

src/commands/send_event.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ use crate::utils::args::{get_timestamp, validate_distribution};
2020
use crate::utils::event::{attach_logfile, get_sdk_info};
2121
use crate::utils::releases::detect_release_name;
2222

23+
/// The maximum number of breadcrumbs to attach to an event.
24+
const MAX_BREADCRUMBS: usize = 100;
25+
2326
pub fn make_command(command: Command) -> Command {
2427
command.about("Send a manual event to Sentry.")
2528
.long_about(
@@ -143,7 +146,7 @@ pub fn make_command(command: Command) -> Command {
143146
Arg::new("logfile")
144147
.value_name("PATH")
145148
.long("logfile")
146-
.help("Send a logfile as breadcrumbs with the event (last 100 records)"),
149+
.help(format!("Send a logfile as breadcrumbs with the event (last {MAX_BREADCRUMBS} records)")),
147150
)
148151
.arg(
149152
Arg::new("with_categories")
@@ -322,7 +325,12 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
322325
}
323326

324327
if let Some(logfile) = matches.get_one::<String>("logfile") {
325-
attach_logfile(&mut event, logfile, matches.get_flag("with_categories"))?;
328+
attach_logfile(
329+
&mut event,
330+
logfile,
331+
matches.get_flag("with_categories"),
332+
MAX_BREADCRUMBS,
333+
)?;
326334
}
327335

328336
let id = send_raw_event(event)?;

src/utils/event.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ lazy_static! {
1313
}
1414

1515
/// Attaches all logs from a logfile as breadcrumbs to the given event.
16-
pub fn attach_logfile(event: &mut Event<'_>, logfile: &str, with_component: bool) -> Result<()> {
16+
pub fn attach_logfile(
17+
event: &mut Event<'_>,
18+
logfile: &str,
19+
with_component: bool,
20+
max_breadcrumbs: usize,
21+
) -> Result<()> {
1722
let f = fs::File::open(logfile).context("Could not open logfile")?;
1823

1924
// sentry currently requires timestamps for breadcrumbs at all times.
@@ -46,8 +51,8 @@ pub fn attach_logfile(event: &mut Event<'_>, logfile: &str, with_component: bool
4651
})
4752
}
4853

49-
if event.breadcrumbs.len() > 100 {
50-
let skip = event.breadcrumbs.len() - 100;
54+
if event.breadcrumbs.len() > max_breadcrumbs {
55+
let skip = event.breadcrumbs.len() - max_breadcrumbs;
5156
event.breadcrumbs.values.drain(..skip);
5257
}
5358

src/utils/vcs.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ fn find_merge_base_ref(
284284
}
285285

286286
/// Attempts to get the base repository name from git remotes.
287-
/// Prefers "origin" remote if it exists, otherwise uses the first available remote.
287+
/// Prefers "upstream" remote if it exists, then "origin", otherwise uses the first available remote.
288288
/// Returns the base repository name if a remote is found.
289289
pub fn git_repo_base_repo_name(repo: &git2::Repository) -> Result<Option<String>> {
290290
let remotes = repo.remotes()?;
@@ -295,8 +295,10 @@ pub fn git_repo_base_repo_name(repo: &git2::Repository) -> Result<Option<String>
295295
return Ok(None);
296296
}
297297

298-
// Prefer "origin" remote if it exists, otherwise use the first one
299-
let chosen_remote = if remote_names.contains(&"origin") {
298+
// Prefer "upstream" if it exists, then "origin", otherwise use the first one
299+
let chosen_remote = if remote_names.contains(&"upstream") {
300+
"upstream"
301+
} else if remote_names.contains(&"origin") {
300302
"origin"
301303
} else {
302304
remote_names[0]

0 commit comments

Comments
 (0)