hey, have a quick question about using `--changed-...
# general
p
hey, have a quick question about using
--changed-since
flag in v1.30 when using a custom target
we have a plugin that is building Go Buildpacks for us but when i use the --changed-since flag and a git commit hash it seems like the only changes pants will monitor are changes to the build files themselves.
do i need to define sources or take some other step to get pants to monitor certain files for changes between commits?
h
Hey @proud-jackal-16497! Hm you might be hitting a weird transition between the old v1 API with the new Target API Do you remember writing Target API bindings? Something like:
Copy code
class CustomTarget(Target):
    alias = "my_tgt"
    core_fields = (Sources, ...)
p
yup our target looks like this
Copy code
class GoTarget(PackTarget):
    """
    Target to generate a Go based buildpack
    """
    alias = "go_pack"
    core_fields = (*COMMON_TARGET_FIELDS, Dependencies, Sources)
but we also have the old bindings defined to support v1 (build file aliases)
and hey @hundreds-father-404 thanks for the quick response!
❤️ 1
h
Okay cool, looks like you are subclassing
Sources
from
pants.engine.target
? That was my first suspicion if you had been using a custom field rather than the predefined one What is
PackTarget
here?
p
basically it's just Target
1
Copy code
class PackTarget(Target):
    pass
h
What does
./pants filedeps2 path/to:tgt
show?
(Btw, it's useful to run the command
./pants --changed-since=HEAD list
to test how
--changed-since
is behaving.)
p
ah well it just shows the BUILD file
👀 1
when listing the target in BUILD
h
Interesting, that is the first thing to address Oh! Are you using a default
sources
value for v1 but not for v2? Or you are setting
sources=
in the BUILD file explicitly
p
nope
that's what i was just about ask lol
h
What does
./pants filedeps path/to:tgt
show? Note that's the v1 implementation of
filedeps
p
it's a custom target with all default attrs
our build file is just:
Copy code
go_pack()
currently
would i manually add everything via sources?
h
Oh, that explains it then.
pants.engine.target.Sources
has a default of
()
(i.e. no default) Instead, do this
Copy code
class GoPackSources(Sources):
   default = ("*.go", "foo.my_ext", "!ignore_me.ext")
There will prob be some unfortunate duplication between v1 and v2 bindings - sorry for that
p
oh ok gotcha that makes sense
do i need to do anything with GoPackSources other than define/register it?
like should it go in the BUILD file somewhere?
h
Nope, only create the class and then update
GoPack.core_fields
to use it instead of
Sources
Then run
./pants filedeps2
to make sure it works how you want
p
oh i see!
got it, will give that a try - thanks!
❤️ 1