TortoiseSVN 1.5 和更新版本可以使用實作 IBugtraqProvider 介面的外掛程式。該介面提供了數個外掛程式可用的方法,用於與問題追蹤器進行互動。
HRESULT ValidateParameters ( // Parent window for any UI that needs to be // displayed during validation. [in] HWND hParentWnd, // The parameter string that needs to be validated. [in] BSTR parameters, // Is the string valid? [out, retval] VARIANT_BOOL *valid );
此方法會從設定對話方塊中呼叫,使用者可在其中新增並設定外掛程式。外掛程式可以使用 parameters
字串取得更多必要資訊,例如問題追蹤器的 URL、登入資訊等。外掛程式應驗證 parameters
字串,如果字串無效,則顯示錯誤對話方塊。 hParentWnd
參數應被用於外掛程式顯示的任何對話方塊 (做為父視窗)。如果 parameters
字串的驗證成功,則外掛程式必須傳回 TRUE。如果外掛程式傳回 FALSE,則設定對話方塊將不允許使用者將外掛程式新增至工作副本路徑。
HRESULT GetLinkText ( // Parent window for any (error) UI that needs to be displayed. [in] HWND hParentWnd, // The parameter string, just in case you need to talk to your // web service (e.g.) to find out what the correct text is. [in] BSTR parameters, // What text do you want to display? // Use the current thread locale. [out, retval] BSTR *linkText );
外掛程式可以在此提供一個字串,用於 TortoiseSVN 提交對話方塊中的按鈕 (呼叫外掛程式時用),例如「選擇問題」或「選取標籤」。請確定字串不要太長,否則可能無法顯示在按鈕中。如果方法傳回錯誤 (例如 E_NOTIMPL
),則會為按鈕使用預設文字。
HRESULT GetCommitMessage ( // Parent window for your provider's UI. [in] HWND hParentWnd, // Parameters for your provider. [in] BSTR parameters, [in] BSTR commonRoot, [in] SAFEARRAY(BSTR) pathList, // The text already present in the commit message. // Your provider should include this text in the new message, // where appropriate. [in] BSTR originalMessage, // The new text for the commit message. // This replaces the original message. [out, retval] BSTR *newMessage );
這是外掛程式的主要方法。當使用者按一下外掛程式按鈕時,此方法會從 TortoiseSVN 提交對話方塊中呼叫。
parameters
字串是使用者在 設定對話方塊中設定外掛程式時必須輸入的字串。外掛程式通常會使用此字串找出問題追蹤器的 URL 和/或登入資訊或更多資訊。
commonRoot
字串包含選取開啟提交對話方塊的所有項目的父路徑。請注意,並非 使用者在提交對話方塊中選取的所有項目的根路徑。對於分支/標籤對話方塊,此為要複製的路徑。
pathList
參數包含使用者針對提交選取的路徑陣列 (為字串)。
originalMessage
參數包含提交對話方塊中日誌訊息方塊輸入的文字。如果使用者尚未輸入任何文字,則此字串將為空字串。
newMessage
傳回字串會複製到提交對話方塊中的日誌訊息編輯方塊,取代原本的內容。如果外掛程式未修改 originalMessage
字串,則必須在此處再次傳回相同的字串,否則使用者輸入的任何文字都將遺失。