How to block TFS check-ins that contain a specific keyword?

81 Views Asked by At

I want to create a TFS policy that blocks a changeset from being checked in if a certain keyword is found in the diff.

This will allow me to make local changes for testing ideas without worrying that these changes will be mistakanly checked in, as long as I add something like //nocommit in the code.

How can this be done?

1

There are 1 best solutions below

0
Cece Dong - MSFT On

There is no out-of-box check-in policy to achieve your requirement, you have to customize your own check-in policy and use command tf diff itemspec /noprompt to compare files.

As a suggestion, you could consider using Git version control, create a branch from master and work on the branch. When you are ready to merge your code to master, create a pull request to review the code. In order to protect master, you could set branch policy on master. After you set up a branch policy, you cannot directly push changes to the branch. Changes to the branch are only made through pull requests.