public BranchPatternViewModel(IPolicyEditArgs _policyEditArgs, BranchPattern branchPattern) { // TODO: Complete member initialization this._rawPolicyEditArgs = _policyEditArgs; this._rawBranchPattern = branchPattern; this._branchPolicies = new ObservableCollection<IBranchPolicyViewModel>(); RefreshBranchPolicies(); }
public List <BranchPolicyFailure> EvaluatePendingCheckin(BranchPattern branchPattern, Microsoft.TeamFoundation.VersionControl.Client.IPendingCheckin pendingCheckin) { List <BranchPolicyFailure> branchPolicyFailures = new List <BranchPolicyFailure>(); if (CodeReviewRequired) { bool foundCodeReviewWorkItem = false; bool allCodeReviewsApproved = false; foreach (WorkItemCheckinInfo wiInfo in pendingCheckin.WorkItems.CheckedWorkItems) { if (wiInfo.WorkItem.Type.Name == "Code Review Request") { foundCodeReviewWorkItem = true; if (wiInfo.WorkItem.State == "Closed" || wiInfo.WorkItem.State == "Resolved") { allCodeReviewsApproved = true; foreach (WorkItemLink item in wiInfo.WorkItem.WorkItemLinks) { WorkItem child = wiInfo.WorkItem.Type.Store.GetWorkItem(item.TargetId); if (child.Type.Name == "Code Review Response") { string closedStatus = child.Fields["Closed Status"].Value.ToString(); if (closedStatus != "Looks Good" && closedStatus != "Removed") { allCodeReviewsApproved = false; } } } } } } if (!allCodeReviewsApproved) { if (foundCodeReviewWorkItem) { branchPolicyFailures.Add(new BranchPolicyFailure(string.Format( "{0} Check-in policy [{1}] ({2}):\n" + "All Code Reviews associated with the check-in must be Approved ('Looks Good').", Name, branchPattern.Name, branchPattern.Pattern))); } else { branchPolicyFailures.Add(new BranchPolicyFailure(string.Format( "{0} Check-in policy [{1}] ({2}):\n" + "Check-in must be associated with at least one Code Review.\n" + "All Code Reviews associated with the check-in must be Approved ('Looks Good').", Name, branchPattern.Name, branchPattern.Pattern))); } } } return(branchPolicyFailures); }
private void ExecuteCreateCommand() { BranchPattern newBranchPattern = new BranchPattern("^.*"); newBranchPattern.BranchPolicies.Add(new LockBranchPolicy()); newBranchPattern.BranchPolicies.Add(new CodeReviewBranchPolicy()); newBranchPattern.BranchPolicies.Add(new WorkItemBranchPolicy()); _repo.Add(newBranchPattern); ExecuteResetCommand(); SelectedBranchPattern = (from bpvm in BranchPatterns where bpvm.RawBranchPattern == newBranchPattern select bpvm).Single(); }
public List<BranchPolicyFailure> EvaluatePendingCheckin(BranchPattern branchPattern, Microsoft.TeamFoundation.VersionControl.Client.IPendingCheckin pendingCheckin) { List<BranchPolicyFailure> branchPolicyFailures = new List<BranchPolicyFailure>(); // Evaluate LockPolicy if (WorkItemRequired) { bool foundWorkItems = false; foreach (WorkItemCheckinInfo item in pendingCheckin.WorkItems.CheckedWorkItems) { foundWorkItems = true; } if (!foundWorkItems) { branchPolicyFailures.Add(new BranchPolicyFailure(String.Format( "{0} Check-in policy [{1}] ({2}):\n" + "You must associate at least one work item with the check-in.", Name, branchPattern.Name, branchPattern.Pattern))); } } return branchPolicyFailures; }
public List <BranchPolicyFailure> EvaluatePendingCheckin(BranchPattern branchPattern, Microsoft.TeamFoundation.VersionControl.Client.IPendingCheckin pendingCheckin) { List <BranchPolicyFailure> branchPolicyFailures = new List <BranchPolicyFailure>(); // Evaluate LockPolicy if (WorkItemRequired) { bool foundWorkItems = false; foreach (WorkItemCheckinInfo item in pendingCheckin.WorkItems.CheckedWorkItems) { foundWorkItems = true; } if (!foundWorkItems) { branchPolicyFailures.Add(new BranchPolicyFailure(String.Format( "{0} Check-in policy [{1}] ({2}):\n" + "You must associate at least one work item with the check-in.", Name, branchPattern.Name, branchPattern.Pattern))); } } return(branchPolicyFailures); }
public List<BranchPolicyFailure> EvaluatePendingCheckin(BranchPattern branchPattern, Microsoft.TeamFoundation.VersionControl.Client.IPendingCheckin pendingCheckin) { List<BranchPolicyFailure> branchPolicyFailures = new List<BranchPolicyFailure>(); // Evaluate LockPolicy if (IsLocked) { string byPassState = IsByPassEnabled ? string.Format("Type '{0}' in the comment field to bypass the lock.", BypassString) : "An override has not been configured."; if (!IsByPassEnabled || pendingCheckin.PendingChanges.Comment == null || !System.Text.RegularExpressions.Regex.Match(pendingCheckin.PendingChanges.Comment, BypassString).Success) { branchPolicyFailures.Add(new BranchPolicyFailure(String.Format( "{0} Check-in policy [{1}] ({2}):\n" + "There is a lock one or more of the files that you are checking in.\n{3}\n", Name, branchPattern.Name, branchPattern.Pattern, byPassState))); } } return branchPolicyFailures; }
public List <BranchPolicyFailure> EvaluatePendingCheckin(BranchPattern branchPattern, Microsoft.TeamFoundation.VersionControl.Client.IPendingCheckin pendingCheckin) { List <BranchPolicyFailure> branchPolicyFailures = new List <BranchPolicyFailure>(); // Evaluate LockPolicy if (IsLocked) { string byPassState = IsByPassEnabled ? string.Format("Type '{0}' in the comment field to bypass the lock.", BypassString) : "An override has not been configured."; if (!IsByPassEnabled || pendingCheckin.PendingChanges.Comment == null || !System.Text.RegularExpressions.Regex.Match(pendingCheckin.PendingChanges.Comment, BypassString).Success) { branchPolicyFailures.Add(new BranchPolicyFailure(String.Format( "{0} Check-in policy [{1}] ({2}):\n" + "There is a lock one or more of the files that you are checking in.\n{3}\n", Name, branchPattern.Name, branchPattern.Pattern, byPassState))); } } return(branchPolicyFailures); }
public void Delete(BranchPattern entity) { throw new NotImplementedException(); }
public void Remove(BranchPattern branchPattern) { _collection.Remove(branchPattern); }
public void Add(BranchPattern branchPattern) { _collection.Add(branchPattern); }
public void Delete(BranchPattern entity) { throw new NotImplementedException(); }
public void Remove(BranchPattern branchPattern) { _collection.Remove(branchPattern); }
public void Add(BranchPattern branchPattern) { _collection.Add(branchPattern); }
public List<BranchPolicyFailure> EvaluatePendingCheckin(BranchPattern branchPattern, Microsoft.TeamFoundation.VersionControl.Client.IPendingCheckin pendingCheckin) { List<BranchPolicyFailure> branchPolicyFailures = new List<BranchPolicyFailure>(); if (CodeReviewRequired) { bool foundCodeReviewWorkItem = false; bool allCodeReviewsApproved = false; foreach (WorkItemCheckinInfo wiInfo in pendingCheckin.WorkItems.CheckedWorkItems) { if (wiInfo.WorkItem.Type.Name == "Code Review Request") { foundCodeReviewWorkItem = true; if (wiInfo.WorkItem.State == "Closed" || wiInfo.WorkItem.State == "Resolved") { allCodeReviewsApproved = true; foreach (WorkItemLink item in wiInfo.WorkItem.WorkItemLinks) { WorkItem child = wiInfo.WorkItem.Type.Store.GetWorkItem(item.TargetId); if (child.Type.Name == "Code Review Response") { string closedStatus = child.Fields["Closed Status"].Value.ToString(); if (closedStatus != "Looks Good" && closedStatus != "Removed") allCodeReviewsApproved = false; } } } } } if (!allCodeReviewsApproved) { if (foundCodeReviewWorkItem) { branchPolicyFailures.Add(new BranchPolicyFailure(string.Format( "{0} Check-in policy [{1}] ({2}):\n" + "All Code Reviews associated with the check-in must be Approved ('Looks Good').", Name, branchPattern.Name, branchPattern.Pattern))); } else { branchPolicyFailures.Add(new BranchPolicyFailure(string.Format( "{0} Check-in policy [{1}] ({2}):\n" + "Check-in must be associated with at least one Code Review.\n" + "All Code Reviews associated with the check-in must be Approved ('Looks Good').", Name, branchPattern.Name, branchPattern.Pattern))); } } } return branchPolicyFailures; }