Does anyone know of a good way, through the Client, the command line, or the API, of ensuring that an item has a matching set of labels? For example, we want to ensure that a version of a source code item has a code review label and a build request label before the build is executed. We can take the information in report form (i.e., list all files with a build request label that do not have a code review label at the same version) or as a preventaive measure (i.e., don't allow a build request label unless there is a code review label).
Any ideas or suggestions?
Label Comparison
Moderator: SourceGear
The GUI client shows labels of a file or folder by invoking either the Show History and Show Labels commands. However, only show history allows you to output the results to a file for inclusion in a report.
If you want something automated to prevent builds that don't have labels, you might need to use or modify the the command line client. The CLC has a HISTORY command that shows history output in XML format, but doesn't have a corresponding show labels command. The source for the CLC is available in the Client API installer on the download page, which would allow you to modify it to work exactly like you want.
If you want something automated to prevent builds that don't have labels, you might need to use or modify the the command line client. The CLC has a HISTORY command that shows history output in XML format, but doesn't have a corresponding show labels command. The source for the CLC is available in the Client API installer on the download page, which would allow you to modify it to work exactly like you want.
API Help
What I really need to do is:
A. Produce a list of file versions that have a particular label (whether the label is on the file itself or inherited from a folder) by the string of the label, not label id
THEN
B. For each file version in the list from A, pull the list of labels for that version and make sure the "paired" partner is there. If it is not, report it.
This sounds simple enough to write down, but I'm having a heck of time trying to figure out which API commands will get me there.
Any ideas?
A. Produce a list of file versions that have a particular label (whether the label is on the file itself or inherited from a folder) by the string of the label, not label id
THEN
B. For each file version in the list from A, pull the list of labels for that version and make sure the "paired" partner is there. If it is not, report it.
This sounds simple enough to write down, but I'm having a heck of time trying to figure out which API commands will get me there.
Any ideas?
Almost....
Thanks! The HISTORY code helps with part B, but not with the first part. Getting the list of files (and versions) by label is the tricky part from where I'm sitting....
I think what you want is ClientInstance.BeginLabelQuery(), which works a lot like a history query. You would need to get the label ID first though (passed in through _queryObjectID parameter), since there is no method that takes a label name for this. I think there are examples in the CLC code for getting a label ID from a label name - let me know if you can't find it.