Wojtek
Wojtek

Reputation: 1390

Display ISubscriber TFS plugin message on git push

We are using TFS 2013 with git source control. I want to enforce some rules, for starters checkin/commit message format. TFS does not support git server hooks so I had to write a plugin by implementing ISubscriber interface.

Plugin does partially work - git commits with messages not matching regex rule are rejected on git push. Problem is - custom status message from plugin is not displayed. Only generic message:

! [remote rejected] master -> master (The reference was rejected by a plugin.)
error: failed to push some refs to 'http://repo_server

Is it possible to show custom message from TFS plugin upon GIT push? If yes, what am I doing wrong?

Plugin was mostly copied from here

Code snippet for commit message validation:

var regex = new Regex(@"regex");

foreach (var item in pushNotification.IncludedCommits)
{
   var gitCommit = (TfsGitCommit)repository.LookupObject(requestContext, item);
   string comment = gitCommit.GetComment(requestContext);
   if (!regex.IsMatch(comment))
   {
       statusCode = 1;
       statusMessage = "Wrong commit message format. Proper message: sample_message";
       return EventNotificationStatus.ActionDenied;
   }
}

Upvotes: 0

Views: 579

Answers (1)

Wojtek
Wojtek

Reputation: 1390

It seems that it is not possible at the moment: msdn forums

Modification of messages returned to git client is currently not supported in TFS.

Upvotes: 1

Related Questions