Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,12 @@ jobs:
- name: Setup uv (Pipenv / pip legs)
if: matrix.pipenv != '' || matrix.pip != ''
uses: astral-sh/setup-uv@eb1897b8dc4b5d5bfe39a428a8f2304605e0983c # v7.0.0
with:
# Pin uv: it is the PEP 751 oracle the pylock tests install with,
# and uv 0.13.2 started refusing Pipenv's `environments = []`
# pylock ("target environment is not supported by the lockfile").
# Bump deliberately, after checking the Pipenv pylock legs pass.
version: "0.13.1"

- name: Install the Pythons the Pipenv / pip legs run on
if: matrix.pipenv != '' || matrix.pip != ''
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/pipenv-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ jobs:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install uv
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0
with:
# Pin uv: it is the PEP 751 oracle the pylock tests install with,
# and uv 0.13.2 started refusing Pipenv's `environments = []`
# pylock ("target environment is not supported by the lockfile").
# Bump deliberately, after checking the Pipenv pylock legs pass.
version: "0.13.1"
- name: Install the Pythons the Pipenv releases run on
run: uv python install 3.8 3.12
- name: Build the CLI
Expand Down
19 changes: 19 additions & 0 deletions crates/socket-patch-core/src/utils/line_endings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,25 @@ pub(crate) fn terminator(text: &str) -> &'static str {
}
}

/// `text`'s physical lines as `(content, ending)`, ending ∈ {`"\r\n"`,
/// `"\n"`, `""`} (`""` only for an unterminated last line); an empty text
/// has no lines. Indexed like `str::lines()`. For the writers that keep
/// each line's own ending, so a file mixing CRLF and LF comes back with
/// every line they leave alone byte for byte.
pub(crate) fn split_lines(text: &str) -> Vec<(&str, &'static str)> {
text.split_inclusive('\n')
.map(|seg| {
if let Some(content) = seg.strip_suffix("\r\n") {
(content, "\r\n")
} else if let Some(content) = seg.strip_suffix('\n') {
(content, "\n")
} else {
(seg, "")
}
})
.collect()
}

/// `text` with every line break spelled `nl` (`"\r\n"` or `"\n"`):
/// existing `\r\n` pairs are folded first, so the result never holds
/// `\r\r\n`. How a writer spells a recorded fragment in the
Expand Down
17 changes: 1 addition & 16 deletions crates/socket-patch-core/src/vendor/cargo_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ use toml_edit::{DocumentMut, InlineTable, Item, Value};

use crate::formats::text::split_bom;
use crate::utils::fs::{atomic_write_bytes_preserving_mode, read_regular_to_string};
use crate::utils::line_endings::split_lines;

use super::cargo_config::{ensure_table_like, patch_entries, path_is_socket_owned};

Expand Down Expand Up @@ -287,22 +288,6 @@ pub fn reconcile_line_endings(original: &str, edited: &str) -> String {
out
}

/// `(content, ending)` per line, ending ∈ {`"\r\n"`, `"\n"`, `""`}; an
/// empty text has no lines.
fn split_lines(text: &str) -> Vec<(&str, &str)> {
text.split_inclusive('\n')
.map(|seg| {
if let Some(content) = seg.strip_suffix("\r\n") {
(content, "\r\n")
} else if let Some(content) = seg.strip_suffix('\n') {
(content, "\n")
} else {
(seg, "")
}
})
.collect()
}

// ── pure transforms ──────────────────────────────────────────────────────────

/// Why the manifest could not be read or edited. Each variant has a stable
Expand Down
Loading
Loading