2016-05-13 32 views
1

我正在使用VS 2013 & TFS源代碼管理服務器。我已經定義了代碼審查的簽入策略,該策略強制開發人員在簽入時附加一個批准的代碼審查請求。我正在使用Colin的ALM Checkin插件以及發送代碼審查。 https://visualstudiogallery.msdn.microsoft.com/c476b708-77a8-4065-b9d0-919ab688f078使用TFS遍地插件的代碼審查過程

對於JAVA代碼,我使用的Eclipse插件團隊資源管理器無處不在。我想從eclipse開發環境中獲得類似的功能。我檢查了這個鏈接https://msdn.microsoft.com/en-us/library/gg475890(v=vs.100).aspx

使用eclipse插件,我可以看到強制開發人員附加工作項的選項,但我想限制它爲代碼請求工作項而不是任何其他工作項類型。

enter image description here

我有以下問題

  1. 是否有可能與Eclipse環境相似的代碼審查過程?
  2. eclipse是否有類似於科林插件的插件,它可以幫助開發人員輕鬆地請求代碼審查&響應。

回答

2

Colin的Checkin插件是自定義簽入策略,TFS支持這種自定義簽入策略。因此,您可以使用適用於Java的SDK構建類似的自定義簽入策略。

開發之前辦理登機手續的政策,您需要:

  1. 下載並安裝

  2. 爲Eclipse添加TEE的插件開發過

  3. 創建一個插件項目

這裏是一個blog,可提供詳細的步驟來開發,測試和部署Eclipse IDE和TFS的自定義註釋檢查策略。你可以把它作爲參考。

此外,下面的代碼(捕獲來自this article)是代碼審查的例子赤,在2012年TFS的政策,這將有助於您:

package com.ssgs.tfs.policies.codereview; 

import java.util.ArrayList; 
import java.util.List; 

import org.eclipse.swt.SWT; 
import org.eclipse.swt.widgets.MessageBox; 
import org.eclipse.swt.widgets.Shell; 

import com.microsoft.tfs.core.checkinpolicies.PolicyBase; 
import com.microsoft.tfs.core.checkinpolicies.PolicyContext; 
import com.microsoft.tfs.core.checkinpolicies.PolicyContextKeys; 
import com.microsoft.tfs.core.checkinpolicies.PolicyEditArgs; 
import com.microsoft.tfs.core.checkinpolicies.PolicyEvaluationCancelledException; 
import com.microsoft.tfs.core.checkinpolicies.PolicyFailure; 
import com.microsoft.tfs.core.checkinpolicies.PolicyType; 
import com.microsoft.tfs.core.checkinpolicies.events.PolicyStateChangedListener; 
import com.microsoft.tfs.core.clients.versioncontrol.soapextensions.WorkItemCheckinInfo; 
import com.microsoft.tfs.core.clients.workitem.WorkItem; 
import com.microsoft.tfs.core.memento.Memento; 
import com.microsoft.tfs.core.pendingcheckin.PendingCheckin; 

public class CodeReviewCheckinPolicyClass extends PolicyBase { 

    private final static PolicyType TYPE = new PolicyType(
       "com.ssgs.tfs.policies.codereview.CodeReviewCheckinPolicyInstance", 
       "Code Review Checkin Policy","Disallows checkin if Code Review work item with approved state is not associated with the check-in", 
       "This check-in policy forces developers to get their code reviewed from experts before it can be checked in. " 
        + "It checks for associated work item of the type Code Review that has state of approved.", 
       "Download the check-in policy package and install it in your Eclipse"); 

    public CodeReviewCheckinPolicyClass() { 
     super(); 
    } 

    @Override 
    public void close() { 
     // TODO Auto-generated method stub 

    } 

    @Override 
    public void activate(PolicyFailure arg0, PolicyContext context) { 
     final Shell shell = (Shell) context.getProperty(PolicyContextKeys.SWT_SHELL); 

     if (shell == null) 
     { 
      return; 
     } 

     /* 
     * activate() is called on the UI thread, so we don't have to explicitly 
     * run our work on the UI thread. 
     */ 
     final MessageBox helpMessageBox = new MessageBox(shell, SWT.ICON_INFORMATION); 
     helpMessageBox.setText("Activation Dialog"); 
     helpMessageBox.setMessage("Policy activated."); 
     helpMessageBox.open(); 
    } 


    @Override 
    public void addPolicyStateChangedListener(PolicyStateChangedListener arg0) { 
     // TODO Auto-generated method stub 

    } 

    @Override 
    public boolean canEdit() { 
     return false; 
    } 

    @Override 
    public void displayHelp(PolicyFailure arg0, PolicyContext context) { 
     final Shell shell = (Shell) context.getProperty(PolicyContextKeys.SWT_SHELL); 

     if (shell == null) 
     { 
      return; 
     } 

     /* 
     * displayHelp() is called on the UI thread, so we don't have to 
     * explicitly run our work on the UI thread. 
     */ 
     final MessageBox helpMessageBox = new MessageBox(shell, SWT.ICON_INFORMATION); 
     helpMessageBox.setText("Code Review Check-in Policy Help"); 
     helpMessageBox.setMessage("Associate a code review check-in policy with Approved state to successfully checking in the pending changes"); 
     helpMessageBox.open(); 
    } 

    @Override 
    public boolean edit(PolicyEditArgs arg0) { 
     return false; 
    } 

    @Override 
    public PolicyFailure[] evaluate(PolicyContext context) 
       throws PolicyEvaluationCancelledException 
       { 
        final PendingCheckin pc = getPendingCheckin(); 
        final List<PolicyFailure> failures = new ArrayList<PolicyFailure>(); 

        final WorkItemCheckinInfo[] AssociatedWorkItems = pc.getWorkItems().getCheckedWorkItems(); 
        WorkItem AssociatedCodeReview = null; 
        String failureReason = ""; 
        for (int i=0; i<AssociatedWorkItems.length; i++) 
        { 
        AssociatedCodeReview = AssociatedWorkItems[i].getWorkItem(); 
        if (AssociatedCodeReview.getType().getName() == "Code Review") 
        { 
         break; 
        } 
        } 
        if (AssociatedCodeReview != null) 
        { 
        if (AssociatedCodeReview.getFields().getField("System.State").getValue().toString().equals("Not Approved")) 
        { 

          failureReason = "Code Review Work Item associated but that is not approved by expert"; 
          failures.add(new PolicyFailure(failureReason, this)); 
        } 
        } 
        else 
        { 
         failureReason = "Code Review Work Item not associated"; 
         failures.add(new PolicyFailure(failureReason, this)); 
        } 

        return failures.toArray(new PolicyFailure[failures.size()]); 

    } 

    @Override 
    public PolicyType getPolicyType() { 
     return CodeReviewCheckinPolicyClass.TYPE; 
    } 

    @Override 
    public void removePolicyStateChangedListener(PolicyStateChangedListener arg0) { 
     // TODO Auto-generated method stub 

    } 

    @Override 
    public void loadConfiguration(Memento arg0) { 
     // TODO Auto-generated method stub 

    } 

    @Override 
    public void saveConfiguration(Memento arg0) { 
     // TODO Auto-generated method stub 

    } 

} 
+1

這解決了一個問題,在那裏我可以執行代碼簽入策略,另一個問題是我想從eclipse編輯器中創建代碼審查請求。科林代碼審查插件有。我如何從Eclipse編輯器創建代碼審閱請求? –