https://pantsbuild.org/ logo
p

proud-jackal-16497

04/30/2021, 6:40 PM
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

hundreds-father-404

04/30/2021, 6:44 PM
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

proud-jackal-16497

04/30/2021, 6:45 PM
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

hundreds-father-404

04/30/2021, 6:47 PM
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

proud-jackal-16497

04/30/2021, 6:47 PM
basically it's just Target
1
Copy code
class PackTarget(Target):
    pass
h

hundreds-father-404

04/30/2021, 6:49 PM
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

proud-jackal-16497

04/30/2021, 6:51 PM
ah well it just shows the BUILD file
👀 1
when listing the target in BUILD
h

hundreds-father-404

04/30/2021, 6:52 PM
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

proud-jackal-16497

04/30/2021, 6:52 PM
nope
that's what i was just about ask lol
h

hundreds-father-404

04/30/2021, 6:52 PM
What does
./pants filedeps path/to:tgt
show? Note that's the v1 implementation of
filedeps
p

proud-jackal-16497

04/30/2021, 6:53 PM
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

hundreds-father-404

04/30/2021, 6:54 PM
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

proud-jackal-16497

04/30/2021, 6:57 PM
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

hundreds-father-404

04/30/2021, 6:58 PM
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

proud-jackal-16497

04/30/2021, 6:59 PM
oh i see!
got it, will give that a try - thanks!
❤️ 1
5 Views