I know that I can use `--changed-since` to operate...
# general
b
I know that I can use
--changed-since
to operate on files and targets that have changed relative to a prior commit. Is there a built-in way that I can flip this around to answer the question "did this particular target (and anything it depends on) have any changes relative to a prior commit?" That is, rather than asking "what changed?", I want to ask "Did this specific thing change?" Thanks in advance.
w
there isn’t… but to calculate it, you could probably intersect
filedeps --transitive
with the git log
b
Yup, I ended up going with this:
Copy code
comm -12 \
	<(./pants --changed-since=$MY_COMMIT filedeps | sort) \
	<(./pants filedeps --transitive $MY_TARGET | sort)
If that outputs anything, something changed 🙂
👀 1
👍 2
h
Neat. Thanks @brash-baker-91190! Think this would be helpful as a tip on https://www.pantsbuild.org/docs/project-introspection? If you're able to share, I'm curious what's motivating the question of
did this particular target (and anything it depends on) have any changes relative to a prior commit?
b
It could be useful, I suppose. My particular use case is determining in my CI/CD pipeline whether or not I should build a container for a particular Python service. I've got some other Python lambdas that I build, and I just use pants directly to build them all based on the
--changed-since
flag, but I can't really do that for a container. I suppose an alternative hacky way to solve this could be to just see if pants would have built the Python wheel for that to-be-containerized service; if it did, I should do a
docker build
🙃
c
I see some potential use for this as well. There are times that we want to run things based on what changed in a repo. Having this ‘what’ condensed down to targets would make that a lot easier ;)
c
Bumping this post because it was useful to us as well. In our case in CI we want to only build and deploy targets that have changes since the last commit.