https://pantsbuild.org/ logo
#general
Title
# general
s

shy-advantage-49800

11/28/2021, 12:44 PM
Copy code
class CustomSetupKwargsRequest(SetupKwargsRequest):
    @classmethod
    def is_applicable(cls, _: Target) -> bool:
        return True


@rule(level=LogLevel.DEBUG)
async def setup_kwargs_plugin(request: CustomSetupKwargsRequest) -> SetupKwargs:
    result = await Get(
        ProcessResult,
        Process(
            argv=["/bin/git", "rev-parse", "--short", "HEAD"],
            description="Retrieve last commit hash.",
        ),
    )
I'm not sure if I'm doing it the way it should be, but is this the right way to get the commit hash? I need to add a
input_digest
and
working_directory
as well, I guess? Am I supposed to create a Snapshot with
.git
? 🤔
h

happy-kitchen-89482

11/28/2021, 2:16 PM
Hmm, we should probably make the git state available as a product you can request, since this is likely a common need. And since copying the
.git
directory into a sandbox every time is likely to be inefficient.
😍 1
Can you file a ticket for this?
Although, now that I think of it, the sandbox is somewhere below
.git
, and I think the
git
binary climbs the filesystem until it finds
.git
, so things might just work with no
input_digest
?
Have you tried?
Oh wait no, that is false
the sandbox is in a tmpdir
off to the side
m

modern-wolf-36228

11/28/2021, 5:16 PM
c

curved-television-6568

11/28/2021, 6:45 PM
For read only purposes, would it make sense to support symlinks in the sandbox? Of course, it would be difficult to guarantee that it's not written to..
5 Views