/// <inheritdoc /> public virtual void Update(IPackage initial, IPackage target, string cwd) { var name = target.GetName(); var from = initial.GetVersionPrettyFull(); var to = target.GetVersionPrettyFull(); var actionName = BVersionParser.IsUpgrade(initial.GetVersion(), target.GetVersion()) ? "Updating" : "Downgrading"; io.WriteError($" - {actionName} <info>{name}</info> (<comment>{from}</comment> => <comment>{to}</comment>): ", false); Remove(initial, cwd, false); Install(target, cwd, false); io.WriteError(string.Empty); }
/// <inheritdoc /> public void Update(IPackage initial, IPackage target, string cwd) { GuardSourceReferenece(target); var name = target.GetName(); string from, to; if (initial.GetVersionPretty() == target.GetVersionPretty()) { if (target.GetSourceType() == "svn") { from = initial.GetSourceReference(); to = target.GetSourceReference(); } else { // Git's reference, we only need to take the first 7 digits. var fromReference = initial.GetSourceReference(); var toReference = target.GetSourceReference(); from = fromReference.Length >= 7 ? fromReference.Substring(0, 7) : fromReference; to = toReference.Length >= 7 ? toReference.Substring(0, 7) : toReference; } name += $" {initial.GetVersionPretty()}"; } else { from = initial.GetVersionPrettyFull(); to = target.GetVersionPrettyFull(); } var actionName = BVersionParser.IsUpgrade(initial.GetVersion(), target.GetVersion()) ? "Updating" : "Downgrading"; IO.WriteError($" - {actionName} <info>{name}</info> (<comment>{from}</comment> => <comment>{to}</comment>): ", false); SException exception = null; try { CleanChanges(initial, cwd, true); ProcessAction(target.GetSourceUris(), (uri) => { DoUpdate(initial, target, cwd, uri); }); } #pragma warning disable CA1031 catch (SException ex) #pragma warning restore CA1031 { exception = ex; } finally { ReapplyChanges(cwd); } // check metadata repository because in case of missing metadata // code would trigger another exception if (exception == null && IO.IsVerbose && HasMetadataRepository(cwd)) { var message = "Pulling in changes:"; var logs = GetCommitLogs(initial.GetSourceReference(), target.GetSourceReference(), cwd); if (string.IsNullOrEmpty(logs)) { message = "Rolling back changes:"; logs = GetCommitLogs(target.GetSourceReference(), initial.GetSourceReference(), cwd); } if (string.IsNullOrEmpty(logs)) { return; } logs = string.Join("\n", Arr.Map(logs.Split('\n'), line => $" {line}")); // escape angle brackets for proper output in the console. logs = logs.Replace("<", @"\<"); IO.WriteError($" {message}"); IO.WriteError(logs); } else if (exception != null) { ExceptionDispatchInfo.Capture(exception).Throw(); } }