Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.

Commit 3eaca7b

Browse files
committed
Alway pre-process patches, as it's stable enough
1 parent 6322c60 commit 3eaca7b

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/bleep/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ sentry-tracing = "0.31.2"
120120
git-version = "0.3.5"
121121
gix = { version="0.44.1", features = ["blocking-http-transport-reqwest", "blocking-network-client", "pack-cache-lru-static"] }
122122
chbs = "0.1.1"
123-
diffy = "0.3.0"
123+
diffy = { git = "https://github.com/bloopai/diffy" }
124124
git2 = { version = "0.17.1", default-features = false, features = ["https"] }
125125

126126
[target.'cfg(windows)'.dependencies]

server/bleep/src/webserver/git.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -293,22 +293,13 @@ impl<'a> Visit for CreateNewCommit<'a> {
293293

294294
assert_eq!(obj.kind, Kind::Blob);
295295
let blob = changes.iter().fold(obj.data, |base, patch| {
296-
println!("{}", process_patch(patch));
297-
298-
match diffy::Patch::from_str(patch) {
299-
Ok(ok) => diffy::apply(String::from_utf8_lossy(&base).as_ref(), &ok).unwrap(),
300-
Err(_) => {
301-
let processed = process_patch(patch);
302-
println!("{processed}");
303-
304-
diffy::apply(
305-
String::from_utf8_lossy(&base).as_ref(),
306-
&diffy::Patch::from_str(&processed).unwrap(),
307-
)
308-
.unwrap()
309-
}
310-
}
311-
.into()
296+
let processed = process_patch(patch);
297+
let base = String::from_utf8_lossy(&base);
298+
println!("{base}");
299+
300+
diffy::apply(base.as_ref(), &diffy::Patch::from_str(&processed).unwrap())
301+
.unwrap()
302+
.into()
312303
});
313304

314305
let new_id = self.repo.write_blob(&blob).unwrap();
@@ -332,9 +323,8 @@ fn process_patch(patch: &str) -> String {
332323
static RE: OnceCell<regex::Regex> = OnceCell::new();
333324
let empty_line = RE.get_or_init(|| regex::Regex::new(r#"^\w*$"#).unwrap());
334325

326+
// remove empty lines from start and end
335327
let patch = {
336-
// remove empty lines from start and end
337-
338328
let rev = patch
339329
.split('\n')
340330
.rev()

0 commit comments

Comments
 (0)