user897645 February 2016

Is there a way to disable check-in permission based on file extension in TFS 2012?

I need to allow designer work on .aspx,.css,*.html .... etc only and disable his permission for *.cs files.

Is there any way to do that in TFS 2012?

Answers


chief7 February 2016

You write a custom checkin policy for this:

// This method performs the actual policy evaluation. 
// It is called by the policy framework at various points in time
// when policy should be evaluated. In this example, the method 
// is invoked when various asyc events occur that may have 
// invalidated the current list of failures.
public override PolicyFailure[] Evaluate()
{
    string proposedComment = PendingCheckin.PendingChanges.Comment;
    if (PendingCheckin.PendingChanges.Any(x => x.Filename.EndsWith(".cs")) && CurrentUser.CanNotEditCodeFiles)
    {
        return new PolicyFailure[] {
            new PolicyFailure("You are not authorized to edit *.cs files.", this) };
    }
    else
    {
        return new PolicyFailure[0];
    }
}

This code won't compile because I added some pseudo code in there as an example but this approach should cover your use case.

Post Status

Asked in February 2016
Viewed 1,606 times
Voted 6
Answered 1 times

Search




Leave an answer