internal async Task RemoveBranchAsync(RemoteRepositoryBranch branch, IProgress <OperationProgress> progress, CancellationToken cancellationToken) { Verify.Argument.IsNotNull(branch, nameof(branch)); Verify.Argument.IsFalse(branch.IsDeleted, nameof(branch), Resources.ExcSuppliedObjectIsDeleted.UseAsFormat("branch")); var parameters = GetRemoveRemoteReferenceParameters(branch); await Remote.Repository.Accessor .RemoveRemoteReferences .InvokeAsync(parameters, progress, cancellationToken); _remoteTags.Remove(branch.Name); branch.MarkAsDeleted(); InvokeBranchDeleted(branch); //return Remote.Repository.Accessor // .RemoveRemoteReferences.InvokeAsync(parameters, progress, cancellationToken) // .ContinueWith( // t => // { // TaskUtility.PropagateFaultedStates(t); // _remoteTags.Remove(branch.Name); // branch.MarkAsDeleted(); // InvokeBranchDeleted(branch); // }, // cancellationToken, // TaskContinuationOptions.ExecuteSynchronously, // TaskScheduler.Default); }
private void InvokeBranchCreated(RemoteRepositoryBranch branch) { var handler = BranchCreated; if (handler != null) { handler(this, new RemoteReferenceEventArgs(branch)); } }
internal void RemoveBranch(RemoteRepositoryBranch branch) { Verify.Argument.IsNotNull(branch, nameof(branch)); Verify.Argument.IsFalse(branch.IsDeleted, nameof(branch), Resources.ExcSuppliedObjectIsDeleted.UseAsFormat("branch")); var parameters = GetRemoveRemoteReferenceParameters(branch); Remote.Repository.Accessor.RemoveRemoteReferences.Invoke(parameters); _remoteBranches.Remove(branch.Name); branch.MarkAsDeleted(); InvokeBranchDeleted(branch); }
private void InvokeBranchCreated(RemoteRepositoryBranch branch) => BranchCreated?.Invoke(this, new RemoteReferenceEventArgs(branch));
private void OnFetchCompleted(IList <RemoteReferenceData> refs) { var branches = new Dictionary <string, RemoteReferenceData>(refs.Count); var tags = new Dictionary <string, RemoteReferenceData>(refs.Count); foreach (var r in refs) { switch (r.ReferenceType) { case ReferenceType.LocalBranch: branches.Add(r.Name.Substring(GitConstants.LocalBranchPrefix.Length), r); break; case ReferenceType.Tag: tags.Add(r.Name.Substring(GitConstants.TagPrefix.Length), r); break; } } List <RemoteRepositoryBranch> deletedBranches; if (_remoteBranches.Count != 0) { deletedBranches = new List <RemoteRepositoryBranch>(_remoteBranches.Count); if (branches.Count == 0) { deletedBranches.AddRange(_remoteBranches.Values); } else { foreach (var b in _remoteBranches) { if (!branches.ContainsKey(b.Key)) { deletedBranches.Add(b.Value); } else { branches.Remove(b.Key); } } } } else { deletedBranches = null; foreach (var b in _remoteBranches) { branches.Remove(b.Key); } } if (branches.Count != 0) { foreach (var b in branches) { var branch = new RemoteRepositoryBranch(this, b.Key, b.Value.Hash); _remoteBranches.Add(branch.Name, branch); InvokeBranchCreated(branch); } } if (deletedBranches != null && deletedBranches.Count != 0) { foreach (var b in deletedBranches) { _remoteBranches.Remove(b.Name); b.MarkAsDeleted(); InvokeBranchDeleted(b); } } List <RemoteRepositoryTag> deletedTags; if (_remoteTags.Count != 0) { deletedTags = new List <RemoteRepositoryTag>(_remoteTags.Count); if (tags.Count == 0) { deletedTags.AddRange(_remoteTags.Values); } else { foreach (var t in _remoteTags) { if (!tags.ContainsKey(t.Key)) { deletedTags.Add(t.Value); } else { tags.Remove(t.Key); } } } } else { deletedTags = null; foreach (var t in _remoteTags) { if (tags.ContainsKey(t.Key)) { tags.Remove(t.Key); } } } if (tags.Count != 0) { foreach (var t in tags) { var tag = new RemoteRepositoryTag(this, t.Key, t.Value.TagType, t.Value.Hash); _remoteTags.Add(tag.Name, tag); InvokeTagCreated(tag); } } if (deletedTags != null && deletedTags.Count != 0) { foreach (var t in deletedTags) { _remoteTags.Remove(t.Name); t.MarkAsDeleted(); InvokeTagDeleted(t); } } }
private void OnFetchCompleted(IList<RemoteReferenceData> refs) { var branches = new Dictionary<string, RemoteReferenceData>(refs.Count); var tags = new Dictionary<string, RemoteReferenceData>(refs.Count); foreach(var r in refs) { switch(r.ReferenceType) { case ReferenceType.LocalBranch: branches.Add(r.Name.Substring(GitConstants.LocalBranchPrefix.Length), r); break; case ReferenceType.Tag: tags.Add(r.Name.Substring(GitConstants.TagPrefix.Length), r); break; } } List<RemoteRepositoryBranch> deletedBranches; if(_remoteBranches.Count != 0) { deletedBranches = new List<RemoteRepositoryBranch>(_remoteBranches.Count); if(branches.Count == 0) { deletedBranches.AddRange(_remoteBranches.Values); } else { foreach(var b in _remoteBranches) { if(!branches.ContainsKey(b.Key)) { deletedBranches.Add(b.Value); } else { branches.Remove(b.Key); } } } } else { deletedBranches = null; foreach(var b in _remoteBranches) { branches.Remove(b.Key); } } if(branches.Count != 0) { foreach(var b in branches) { var branch = new RemoteRepositoryBranch(this, b.Key, b.Value.Hash); _remoteBranches.Add(branch.Name, branch); InvokeBranchCreated(branch); } } if(deletedBranches != null && deletedBranches.Count != 0) { foreach(var b in deletedBranches) { _remoteBranches.Remove(b.Name); b.MarkAsDeleted(); InvokeBranchDeleted(b); } } List<RemoteRepositoryTag> deletedTags; if(_remoteTags.Count != 0) { deletedTags = new List<RemoteRepositoryTag>(_remoteTags.Count); if(tags.Count == 0) { deletedTags.AddRange(_remoteTags.Values); } else { foreach(var t in _remoteTags) { if(!tags.ContainsKey(t.Key)) { deletedTags.Add(t.Value); } else { tags.Remove(t.Key); } } } } else { deletedTags = null; foreach(var t in _remoteTags) { if(tags.ContainsKey(t.Key)) { tags.Remove(t.Key); } } } if(tags.Count != 0) { foreach(var t in tags) { var tag = new RemoteRepositoryTag(this, t.Key, t.Value.TagType, t.Value.Hash); _remoteTags.Add(tag.Name, tag); InvokeTagCreated(tag); } } if(deletedTags != null && deletedTags.Count != 0) { foreach(var t in deletedTags) { _remoteTags.Remove(t.Name); t.MarkAsDeleted(); InvokeTagDeleted(t); } } }
private void InvokeBranchDeleted(RemoteRepositoryBranch branch) { var handler = BranchDeleted; if(handler != null) handler(this, new RemoteReferenceEventArgs(branch)); }
internal Task RemoveBranchAsync(RemoteRepositoryBranch branch, IProgress<OperationProgress> progress, CancellationToken cancellationToken) { Verify.Argument.IsNotNull(branch, "branch"); Verify.Argument.IsFalse(branch.IsDeleted, "branch", Resources.ExcSuppliedObjectIsDeleted.UseAsFormat("branch")); var parameters = GetRemoveRemoteReferenceParameters(branch); return _remote.Repository.Accessor .RemoveRemoteReferences.InvokeAsync(parameters, progress, cancellationToken) .ContinueWith( t => { TaskUtility.PropagateFaultedStates(t); _remoteTags.Remove(branch.Name); branch.MarkAsDeleted(); InvokeBranchDeleted(branch); }, cancellationToken, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default); }
internal void RemoveBranch(RemoteRepositoryBranch branch) { Verify.Argument.IsNotNull(branch, "branch"); Verify.Argument.IsFalse(branch.IsDeleted, "branch", Resources.ExcSuppliedObjectIsDeleted.UseAsFormat("branch")); var parameters = GetRemoveRemoteReferenceParameters(branch); _remote.Repository.Accessor.RemoveRemoteReferences.Invoke(parameters); _remoteBranches.Remove(branch.Name); branch.MarkAsDeleted(); InvokeBranchDeleted(branch); }