If you're building a CI system, you may also be interested in knowing which target(s) changed as the result of a commit to source control, so you don't build or test too many things.
Buck supports this use-case via the command:
buck targets --show-target-hash [target1] [...]
You can run this twice (once before applying the commit, then again afterwards) to get an identifier for each of the target(s) which is guaranteed to change if any of the inputs or dependencies for the target changes.
This is documented here:
By default, this command hashes the contents of all the files involved in the targets. This might prove to be expensive for very large targets, so in that case you might want to specify the paths which are modified:
buck targets --show-target-hash --target-hash-file-mode=PATHS_ONLY --target-hash-modified-paths="/path/to/file1 /path/to/file2 ..." [target1] [...]
Ben