```class CustomSetupKwargsRequest(SetupKwargsReque...
# general
s
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
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
c
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..