• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 18198316586

02 Oct 2025 03:50PM UTC coverage: 78.82% (-1.4%) from 80.265%
18198316586

push

github

web-flow
Bump serde from 1.0.226 to 1.0.228 in /src/rust (#22723)

Bumps [serde](https://github.com/serde-rs/serde) from 1.0.226 to
1.0.228.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/serde-rs/serde/releases">serde's
releases</a>.</em></p>
<blockquote>
<h2>v1.0.228</h2>
<ul>
<li>Allow building documentation with
<code>RUSTDOCFLAGS='--cfg=docsrs'</code> set for the whole dependency
graph (<a
href="https://redirect.github.com/serde-rs/serde/issues/2995">#2995</a>)</li>
</ul>
<h2>v1.0.227</h2>
<ul>
<li>Documentation improvements (<a
href="https://redirect.github.com/serde-rs/serde/issues/2991">#2991</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/serde-rs/serde/commit/a866b336f"><code>a866b33</code></a>
Release 1.0.228</li>
<li><a
href="https://github.com/serde-rs/serde/commit/5adc9e816"><code>5adc9e8</code></a>
Merge pull request <a
href="https://redirect.github.com/serde-rs/serde/issues/2995">#2995</a>
from dtolnay/rustdocflags</li>
<li><a
href="https://github.com/serde-rs/serde/commit/ab581789f"><code>ab58178</code></a>
Workaround for RUSTDOCFLAGS='--cfg=docsrs'</li>
<li><a
href="https://github.com/serde-rs/serde/commit/415d9fc56"><code>415d9fc</code></a>
Release 1.0.227</li>
<li><a
href="https://github.com/serde-rs/serde/commit/7c58427e1"><code>7c58427</code></a>
Merge pull request <a
href="https://redirect.github.com/serde-rs/serde/issues/2991">#2991</a>
from dtolnay/inlinecoredoc</li>
<li><a
href="https://github.com/serde-rs/serde/commit/9d3410e3f"><code>9d3410e</code></a>
Merge pull request <a
href="https://redirect.github.com/serde-rs/serde/issues/2992">#2992</a>
from dtolnay/inplaceseed</li>
<li><a
href="https://github.com/serde-rs/serde/commit/2fb6748bf1ff93... (continued)

73576 of 93347 relevant lines covered (78.82%)

2.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

47.83
/src/python/pants/fs/fs.py
1
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
import hashlib
10✔
5
import os
10✔
6

7
# The max filename length for HFS+, extX and NTFS is 255, but many systems also have limits on the
8
# total path length (made up of multiple filenames), so we include some additional buffer.
9
_MAX_FILENAME_LENGTH = 100
10✔
10

11

12
def safe_filename(name, extension=None, digest=None, max_length=_MAX_FILENAME_LENGTH):
10✔
13
    """Creates filename from name and extension ensuring that the final length is within the
14
    max_length constraint.
15

16
    By default the length is capped to work on most filesystems and the fallback to achieve
17
    shortening is a sha1 hash of the proposed name.
18

19
    Raises ValueError if the proposed name is not a simple filename but a file path.
20
    Also raises ValueError when the name is simple but cannot be satisfactorily shortened with the
21
    given digest.
22

23
    :API: public
24

25
    name:       the proposed filename without extension
26
    extension:  an optional extension to append to the filename
27
    digest:     the digest to fall back on for too-long name, extension concatenations - should
28
                support the hashlib digest api of update(string) and hexdigest
29
    max_length: the maximum desired file name length
30
    """
31
    if os.path.basename(name) != name:
2✔
32
        raise ValueError(f"Name must be a filename, handed a path: {name}")
×
33

34
    ext = extension or ""
2✔
35
    filename = name + ext
2✔
36
    if len(filename) <= max_length:
2✔
37
        return filename
2✔
38
    else:
39
        digest = digest or hashlib.sha1()
×
40
        digest.update(filename.encode())
×
41
        hexdigest = digest.hexdigest()[:16]
×
42

43
        # Prefix and suffix length: max length less 2 periods, the extension length, and the digest length.
44
        ps_len = max(0, (max_length - (2 + len(ext) + len(hexdigest))) // 2)
×
45
        sep = "." if ps_len > 0 else ""
×
46
        prefix = name[:ps_len]
×
47
        suffix = name[-ps_len:] if ps_len > 0 else ""
×
48

49
        safe_name = f"{prefix}{sep}{hexdigest}{sep}{suffix}{ext}"
×
50
        if len(safe_name) > max_length:
×
51
            raise ValueError(
×
52
                "Digest {} failed to produce a filename <= {} characters for {} - got {}".format(
53
                    digest, max_length, filename, safe_name
54
                )
55
            )
56
        return safe_name
×
57

58

59
def safe_filename_from_path(path, **kwargs):
10✔
60
    """As for `safe_filename`, but takes a path.
61

62
    First converts it into a name by replacing separator characters, and then calls safe_filename.
63
    """
64
    return safe_filename(path.strip(os.path.sep).replace(os.path.sep, "."), **kwargs)
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc