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

pantsbuild / pants / 21552830208

31 Jan 2026 11:40PM UTC coverage: 80.277% (-0.05%) from 80.324%
21552830208

Pull #23062

github

web-flow
Merge 808a9786c into 2c4dcf9cf
Pull Request #23062: Remove support for Get

18 of 25 new or added lines in 4 files covered. (72.0%)

17119 existing lines in 541 files now uncovered.

78278 of 97510 relevant lines covered (80.28%)

3.36 hits per line

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

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

4
import os
12✔
5
from typing import cast
12✔
6

7
from pants.fs.fs import safe_filename_from_path
12✔
8
from pants.option.option_value_container import OptionValueContainer
12✔
9
from pants.util.dirutil import absolute_symlink, safe_mkdir, safe_rmtree
12✔
10

11

12
def init_workdir(global_options: OptionValueContainer) -> str:
12✔
13
    """Given the bootstrap options (generally immediately after bootstrap), initialize the workdir.
14

15
    If it is in use, the "physical" workdir is a directory under the `pants_physical_workdir_base`
16
    that is unique to each working copy (via including the entire path to the working copy in its
17
    name using `safe_filename_from_path`).
18
    """
UNCOV
19
    workdir_src = cast(str, global_options.pants_workdir)
1✔
UNCOV
20
    if not global_options.pants_physical_workdir_base:
1✔
21
        safe_mkdir(workdir_src)
×
22
        return workdir_src
×
23

UNCOV
24
    workdir_base = global_options.pants_physical_workdir_base
1✔
UNCOV
25
    workdir_dst = os.path.join(workdir_base, safe_filename_from_path(workdir_src))
1✔
26

UNCOV
27
    def create_symlink_to_clean_workdir():
1✔
28
        # Executed when no link exists. We treat this as equivalent to a request to have deleted
29
        # this state. Operations like `clean-all` will already have purged the destination, but in
30
        # cases like manual removal of the symlink, we want to treat the case as equivalent.
UNCOV
31
        safe_mkdir(workdir_dst, clean=True)
1✔
UNCOV
32
        absolute_symlink(workdir_dst, workdir_src)
1✔
33

UNCOV
34
    if not os.path.lexists(workdir_src):
1✔
35
        # Does not exist.
36
        create_symlink_to_clean_workdir()
×
UNCOV
37
    elif os.path.islink(workdir_src):
1✔
38
        if os.readlink(workdir_src) != workdir_dst:
×
39
            # Exists but is incorrect.
40
            os.unlink(workdir_src)
×
41
            create_symlink_to_clean_workdir()
×
42
        else:
43
            # Exists and is correct: ensure that the destination exists.
44
            safe_mkdir(workdir_dst)
×
45
    else:
46
        # Remove existing physical workdir (.pants.d/workdir dir)
UNCOV
47
        safe_rmtree(workdir_src)
1✔
48
        # Create both symlink workdir (.pants.d/workdir dir) and its destination/physical workdir
UNCOV
49
        create_symlink_to_clean_workdir()
1✔
UNCOV
50
    return workdir_src
1✔
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

© 2026 Coveralls, Inc