///<summary>Returns an ODGridCell formatted to show the status of the backport.</summary> private GridCell GetStatusCell(string backportVersion, ODFileChanges changedFile) { GridCell cell = new GridCell(); ODBackportResult backportResult = _listBackportResults.Find(x => x.FilePathHead == changedFile.FilePathHead); if (backportResult != null) { ResultType result = backportResult.GetResult(backportVersion); int numFailed = backportResult.GetFailedChanges(backportVersion).Count; cell.Text = result.ToString(); switch (result) { case ResultType.Ok: cell.ColorText = Color.DarkGreen; break; case ResultType.Partial: cell.ColorText = Color.YellowGreen; cell.Text += " (" + (changedFile.ListLineChanges.Count - numFailed).ToString() + "/" + changedFile.ListLineChanges.Count + ")"; break; case ResultType.Failed: cell.ColorText = Color.DarkRed; break; case ResultType.None: default: cell.ColorText = Color.Black; cell.Text = ""; break; } } return(cell); }
///<summary>This backports the files that have not been backported yet.</summary> ///<param name="backportVersion">The version that is being backported.</param> ///<param name="listFileChanges">A list of the files that will be backported.</param> public bool BackportFiles(string backportVersion, List <ODFileChanges> listFileChanges) { bool areAllFilesSuccessful = true; foreach (ODFileChanges file in listFileChanges) { ODBackportResult backportResult = new ODBackportResult(); backportResult.FilePathHead = file.FilePathHead; if (_listBackportResults.Any(x => x.FilePathHead == file.FilePathHead)) { backportResult = _listBackportResults.Find(x => x.FilePathHead == file.FilePathHead); } ResultType resultType = backportResult.GetResult(backportVersion); if (resultType != ResultType.None) //Skip already backported files { areAllFilesSuccessful &= resultType == ResultType.Ok; continue; } if (file.ModificationType == FileModificationType.Modified) { resultType = ModifyFile(file, backportVersion, backportResult); } else if (file.ModificationType == FileModificationType.Added) { resultType = AddFile(file, backportVersion); } else if (file.ModificationType == FileModificationType.Deleted) { resultType = DeleteFile(file, backportVersion); } areAllFilesSuccessful &= resultType == ResultType.Ok; backportResult.UpdateResult(backportVersion, resultType); if (!_listBackportResults.Any(x => x.FilePathHead == file.FilePathHead)) //If not added yet, add here. { _listBackportResults.Add(backportResult); } } return(areAllFilesSuccessful); }