Move the path resolver to the constructor.
This will ensure that it's in place before evaluating checkin policies, which is when it is needed, without expanding the interface of ITfsHelper.
This commit is contained in:
@@ -363,8 +363,6 @@ namespace Sep.Git.Tfs.VsCommon
|
||||
|
||||
protected abstract string GetAuthenticatedUser();
|
||||
|
||||
public abstract void SetPathResolver();
|
||||
|
||||
public abstract bool CanShowCheckinDialog { get; }
|
||||
|
||||
public ITfsChangeset GetShelvesetData(IGitTfsRemote remote, string shelvesetOwner, string shelvesetName)
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace Sep.Git.Tfs.VsCommon
|
||||
: base(stdout, bridge, container)
|
||||
{
|
||||
_bridge = bridge;
|
||||
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(LoadFromVSFolder);
|
||||
}
|
||||
|
||||
public override bool CanGetBranchInformation
|
||||
@@ -220,18 +221,17 @@ namespace Sep.Git.Tfs.VsCommon
|
||||
|
||||
protected abstract string GetVsInstallDir();
|
||||
|
||||
public override void SetPathResolver()
|
||||
{
|
||||
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(LoadFromVSFolder);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Help the TFS client find checkin policy assemblies.
|
||||
/// </summary>
|
||||
Assembly LoadFromVSFolder(object sender, ResolveEventArgs args)
|
||||
{
|
||||
Trace.WriteLine("Looking for assembly " + args.Name + " ...");
|
||||
string folderPath = Path.Combine(GetVsInstallDir(), "PrivateAssemblies");
|
||||
string assemblyPath = Path.Combine(folderPath, new AssemblyName(args.Name).Name + ".dll");
|
||||
if (File.Exists(assemblyPath) == false)
|
||||
return null;
|
||||
Trace.WriteLine("... loading " + args.Name + " from " + assemblyPath);
|
||||
Assembly assembly = Assembly.LoadFrom(assemblyPath);
|
||||
return assembly;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace Sep.Git.Tfs.Core.TfsInterop
|
||||
bool HasShelveset(string shelvesetName);
|
||||
ITfsChangeset GetShelvesetData(IGitTfsRemote remote, string shelvesetOwner, string shelvesetName);
|
||||
int ListShelvesets(ShelveList shelveList, IGitTfsRemote remote);
|
||||
void SetPathResolver();
|
||||
bool CanShowCheckinDialog { get; }
|
||||
long ShowCheckinDialog(IWorkspace workspace, IPendingChange[] pendingChanges, IEnumerable<IWorkItemCheckedInfo> checkedInfos, string checkinComment);
|
||||
void CleanupWorkspaces(string workingDirectory);
|
||||
|
||||
@@ -44,7 +44,6 @@ namespace Sep.Git.Tfs.Core
|
||||
shelveset.WorkItemInfo = GetWorkItemInfos().ToArray();
|
||||
if (evaluateCheckinPolicies)
|
||||
{
|
||||
_tfsHelper.SetPathResolver();
|
||||
foreach (var message in _policyEvaluator.EvaluateCheckin(_workspace, pendingChanges, shelveset.Comment, null, shelveset.WorkItemInfo).Messages)
|
||||
{
|
||||
_stdout.WriteLine("[Checkin Policy] " + message);
|
||||
@@ -64,7 +63,6 @@ namespace Sep.Git.Tfs.Core
|
||||
if (string.IsNullOrWhiteSpace(checkinComment) && !_checkinOptions.NoGenerateCheckinComment)
|
||||
checkinComment = generateCheckinComment();
|
||||
|
||||
_tfsHelper.SetPathResolver();
|
||||
var newChangesetId = _tfsHelper.ShowCheckinDialog(_workspace, pendingChanges, GetWorkItemCheckedInfos(), checkinComment);
|
||||
if (newChangesetId <= 0)
|
||||
throw new GitTfsException("Checkin canceled!");
|
||||
@@ -88,7 +86,6 @@ namespace Sep.Git.Tfs.Core
|
||||
var workItemInfos = GetWorkItemInfos(options);
|
||||
var checkinNote = _tfsHelper.CreateCheckinNote(options.CheckinNotes);
|
||||
|
||||
_tfsHelper.SetPathResolver();
|
||||
var checkinProblems = _policyEvaluator.EvaluateCheckin(_workspace, pendingChanges, options.CheckinComment, checkinNote, workItemInfos);
|
||||
if (checkinProblems.HasErrors)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user