/// <inheritdoc /> public void ChangeItemContent(SourceInformation sourceInformation, TfvcItem existingItem, string content) { Validators.AssertIsNotNull(sourceInformation, nameof(sourceInformation)); Validators.AssertIsNotNull(existingItem, nameof(existingItem)); Validators.AssertIsNotNullOrEmpty(content, nameof(content)); Logger.Trace("Entering"); sourceInformation.AssertIsValid(); sourceInformation.AssertIsSourceType(SourceType.TfsVc); var isAdd = existingItem == null; var item = new TfvcItem { Path = sourceInformation.SourcePath, ContentMetadata = new FileContentMetadata { Encoding = 65001 } }; if (!isAdd) { item.ChangesetVersion = existingItem.ChangesetVersion; } var change = new TfvcChange { ChangeType = isAdd ? VersionControlChangeType.Add : VersionControlChangeType.Edit, NewContent = new ItemContent { Content = Convert.ToBase64String(Encoding.UTF8.GetBytes(content)), ContentType = ItemContentType.Base64Encoded }, Item = item }; var changeset = new TfvcChangeset { Comment = "Automatically " + (isAdd ? "Added" : "Updated") + " from API", Changes = new List <TfvcChange> { change } //PolicyOverride = new TfvcPolicyOverrideInfo("API", null), }; // submit the changeset var result = _client.Value.CreateChangesetAsync( changeset, VsTsTool.GetProjectNameFromPath(sourceInformation.SourcePath)) .Result; Console.WriteLine($"Changeset created for Add/Update. Id: {result.ChangesetId}."); }
/// <inheritdoc /> public void DeleteItem(SourceInformation sourceInformation, TfvcItem existingItem) { Validators.AssertIsNotNull(sourceInformation, nameof(sourceInformation)); Validators.AssertIsNotNull(existingItem, nameof(existingItem)); sourceInformation.AssertIsValid(); sourceInformation.AssertIsSourceType(SourceType.TfsVc); Logger.Trace("Entering"); var item = new TfvcItem { Path = sourceInformation.SourcePath, ContentMetadata = new FileContentMetadata { Encoding = 65001 }, ChangesetVersion = existingItem.ChangesetVersion }; var change = new TfvcChange { ChangeType = VersionControlChangeType.Delete, Item = item }; var changeset = new TfvcChangeset { Comment = "Automatically deleted from API", Changes = new List <TfvcChange> { change } //PolicyOverride = new TfvcPolicyOverrideInfo("API", null), }; // submit the changeset var result = _client.Value.CreateChangesetAsync( changeset, VsTsTool.GetProjectNameFromPath(sourceInformation.SourcePath)) .Result; Console.WriteLine($"Changeset created for delete. Id: {result.ChangesetId}."); }
private static string GetGroupKey(TfvcChange c) { //Console.WriteLine("{0}", c.ChangeType); return c.Item.Path; }
private static string GetGroupKey(TfvcChange c) { //Console.WriteLine("{0}", c.ChangeType); return(c.Item.Path); }