/// <summary> /// Picks latest label from the provided group and returns its name. /// </summary> /// <param name="Labels">Labels to chose from.</param> /// <param name="bVerifyContent">If the method should skip labels that has no tagged files in it.</param> /// <returns>The name of the label. If none was valid returns null.</returns> public static string PickLatest(P4Label[] Labels, bool bVerifyContent) { if (Labels.Length == 0) { return(null); } var OrderedLabels = Labels.OrderByDescending((Label) => Label.Date); if (bVerifyContent) { foreach (var Label in OrderedLabels) { if (P4.ValidateLabelContent(Label.Name)) { return(Label.Name); } } // Haven't found valid label. return(null); } return(OrderedLabels.First().Name); }
public override void ExecuteBuild() { var Preview = ParseParam("preview"); var ArtistSync = ParseParam("artist"); var BranchPath = CommandUtils.GetDirectoryName(P4Env.BuildRootP4); var LabelParam = ParseParamValue("label"); var GameName = ParseParamValue("game"); if (GameName == null) { GameName = ""; } string ProgramSyncLabelName = null; if (!string.IsNullOrWhiteSpace(LabelParam)) { if (!LabelParam.StartsWith(BranchPath) || !P4.ValidateLabelContent(LabelParam)) { throw new AutomationException("Label {0} either doesn't exist or is not valid for the current branch path {1}.", LabelParam, BranchPath); } ProgramSyncLabelName = LabelParam; } else { ProgramSyncLabelName = GetLatestPromotedLabel(BranchPath, GameName, true); } if (ProgramSyncLabelName == null) { throw new AutomationException("Label for {0} was not found.", string.IsNullOrWhiteSpace(GameName) ? string.Format("branch {0} shared-promotable", BranchPath) : string.Format("branch {0} and game {1}", BranchPath, GameName)); } SyncToLabel(BranchPath, ProgramSyncLabelName, ArtistSync, Preview); }