Skip to content

Commit 08a6c2b

Browse files
authored
Merge branch 'main' into date-positional-set-format
2 parents 9e6de13 + 07d6f27 commit 08a6c2b

21 files changed

Lines changed: 780 additions & 247 deletions

File tree

.github/workflows/GnuComment.yml

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,44 @@ jobs:
4949
with:
5050
github-token: ${{ secrets.GITHUB_TOKEN }}
5151
script: |
52-
var fs = require('fs');
53-
var issue_number = Number(fs.readFileSync('./NR'));
54-
var content = fs.readFileSync('./result.txt');
55-
if (content.toString().trim().length > 7) { // 7 because we have backquote + \n
52+
const fs = require('fs');
53+
if (!fs.existsSync('./NR') || !fs.existsSync('./result.txt')) {
54+
core.info("No GNU comment payload to post.");
55+
return;
56+
}
57+
const issue_number = Number(fs.readFileSync('./NR'));
58+
if (!issue_number) {
59+
core.info('No PR number; skipping.');
60+
return;
61+
}
62+
const content = fs.readFileSync('./result.txt').toString();
63+
64+
const marker = '<!-- gnu-comment-bot -->';
65+
const body = `${marker}\nGNU testsuite comparison:\n\`\`\`\n${content}\n\`\`\``;
66+
67+
const { data: comments } = await github.rest.issues.listComments({
68+
...context.repo,
69+
issue_number
70+
});
71+
72+
const existing = comments.find(c =>
73+
c.user.login === 'github-actions[bot]' &&
74+
c.body.includes(marker)
75+
);
76+
77+
if (existing) {
78+
await github.rest.issues.updateComment({
79+
...context.repo,
80+
comment_id: existing.id,
81+
body
82+
});
83+
} else {
84+
if (content.trim().length <= 7) { // 7 because we have backquote + \n
85+
return;
86+
}
5687
await github.rest.issues.createComment({
57-
owner: context.repo.owner,
58-
repo: context.repo.repo,
59-
issue_number: issue_number,
60-
body: 'GNU testsuite comparison:\n```\n' + content + '```'
88+
...context.repo,
89+
issue_number,
90+
body
6191
});
6292
}

Cargo.lock

Lines changed: 20 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ clap_complete = "4.4"
398398
clap_mangen = "0.3"
399399
compare = "0.1.0"
400400
crossterm = { version = "0.29.0", default-features = false }
401-
ctor = "0.9.0"
401+
ctor = "0.10.0"
402402
ctrlc = { version = "3.5.2", features = ["termination"] }
403403
divan = { package = "codspeed-divan-compat", version = "4.4.1" }
404404
dns-lookup = { version = "3.0.0" }
@@ -487,7 +487,6 @@ digest = "0.10.7"
487487

488488
# Fluent dependencies
489489
fluent = "0.17.0"
490-
fluent-bundle = "0.16.0"
491490
unic-langid = "0.9.6"
492491
fluent-syntax = "0.12.0"
493492

fuzz/Cargo.lock

Lines changed: 0 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uu/cat/src/cat.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,12 @@ fn get_input_type(path: &OsString) -> CatResult<InputType> {
479479
fn write_fast<R: FdReadable>(handle: &mut InputHandle<R>) -> CatResult<()> {
480480
let stdout = io::stdout();
481481
#[cfg(any(target_os = "linux", target_os = "android"))]
482+
let mut stdout = stdout;
483+
#[cfg(any(target_os = "linux", target_os = "android"))]
482484
{
483485
// If we're on Linux or Android, try to use the splice() system call
484486
// for faster writing. If it works, we're done.
485-
if !splice::write_fast_using_splice(handle, &stdout)? {
487+
if !splice::write_fast_using_splice(handle, &mut stdout)? {
486488
return Ok(());
487489
}
488490
}

src/uu/cat/src/splice.rs

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44
// file that was distributed with this source code.
55
use super::{CatResult, FdReadable, InputHandle};
66

7-
use rustix::io::{read, write};
7+
use std::io::{Read, Write};
88
use std::os::{fd::AsFd, unix::io::AsRawFd};
99

1010
use uucore::pipes::{MAX_ROOTLESS_PIPE_SIZE, might_fuse, pipe, splice, splice_exact};
1111

12-
const BUF_SIZE: usize = 1024 * 16;
13-
1412
/// This function is called from `write_fast()` on Linux and Android. The
1513
/// function `splice()` is used to move data between two file descriptors
1614
/// without copying between kernel and user spaces. This results in a large
@@ -19,14 +17,14 @@ const BUF_SIZE: usize = 1024 * 16;
1917
/// The `bool` in the result value indicates if we need to fall back to normal
2018
/// copying or not. False means we don't have to.
2119
#[inline]
22-
pub(super) fn write_fast_using_splice<R: FdReadable, S: AsRawFd + AsFd>(
20+
pub(super) fn write_fast_using_splice<R: FdReadable, S: AsRawFd + AsFd + Write>(
2321
handle: &InputHandle<R>,
24-
write_fd: &S,
22+
write_fd: &mut S,
2523
) -> CatResult<bool> {
2624
if splice(&handle.reader, &write_fd, MAX_ROOTLESS_PIPE_SIZE).is_ok() {
2725
// fcntl improves throughput
2826
// todo: avoid fcntl overhead for small input, but don't fcntl inside of the loop
29-
let _ = rustix::pipe::fcntl_setpipe_size(write_fd, MAX_ROOTLESS_PIPE_SIZE);
27+
let _ = rustix::pipe::fcntl_setpipe_size(&mut *write_fd, MAX_ROOTLESS_PIPE_SIZE);
3028
loop {
3129
match splice(&handle.reader, &write_fd, MAX_ROOTLESS_PIPE_SIZE) {
3230
Ok(1..) => {}
@@ -46,7 +44,9 @@ pub(super) fn write_fast_using_splice<R: FdReadable, S: AsRawFd + AsFd>(
4644
// we can recover by copying the data that we have from the
4745
// intermediate pipe to stdout using normal read/write. Then
4846
// we tell the caller to fall back.
49-
copy_exact(&pipe_rd, write_fd, n)?;
47+
let mut drain = Vec::with_capacity(n); // bounded by pipe size
48+
pipe_rd.take(n as u64).read_to_end(&mut drain)?;
49+
write_fd.write_all(&drain)?;
5050
return Ok(true);
5151
}
5252
}
@@ -57,24 +57,3 @@ pub(super) fn write_fast_using_splice<R: FdReadable, S: AsRawFd + AsFd>(
5757
Ok(true)
5858
}
5959
}
60-
61-
/// Move exactly `num_bytes` bytes from `read_fd` to `write_fd`.
62-
///
63-
/// Panics if not enough bytes can be read.
64-
fn copy_exact(read_fd: &impl AsFd, write_fd: &impl AsFd, num_bytes: usize) -> std::io::Result<()> {
65-
let mut left = num_bytes;
66-
let mut buf = [0; BUF_SIZE];
67-
while left > 0 {
68-
let n = read(read_fd, &mut buf)?;
69-
assert_ne!(n, 0, "unexpected end of pipe");
70-
let mut written = 0;
71-
while written < n {
72-
match write(write_fd, &buf[written..n])? {
73-
0 => unreachable!("fd should be writable"),
74-
w => written += w,
75-
}
76-
}
77-
left -= n;
78-
}
79-
Ok(())
80-
}

src/uu/date/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ jiff = { workspace = true, features = [
4040
"tzdb-concatenated",
4141
] }
4242
parse_datetime = { workspace = true }
43-
regex = { workspace = true }
4443
uucore = { workspace = true, features = ["parser", "i18n-datetime"] }
4544

4645
[target.'cfg(unix)'.dependencies]

0 commit comments

Comments
 (0)