Пример #1
0
        internal async Task RemoveTagAsync(RemoteRepositoryTag tag, IProgress <OperationProgress> progress, CancellationToken cancellationToken)
        {
            Verify.Argument.IsNotNull(tag, nameof(tag));
            Verify.Argument.IsFalse(tag.IsDeleted, nameof(tag),
                                    Resources.ExcSuppliedObjectIsDeleted.UseAsFormat("tag"));

            var parameters = GetRemoveRemoteReferenceParameters(tag);
            await Remote.Repository.Accessor
            .RemoveRemoteReferences.InvokeAsync(parameters, progress, cancellationToken);

            _remoteTags.Remove(tag.Name);
            tag.MarkAsDeleted();
            InvokeTagDeleted(tag);

            //return Remote.Repository.Accessor
            //	.RemoveRemoteReferences.InvokeAsync(parameters, progress, cancellationToken)
            //	.ContinueWith(
            //	t =>
            //	{
            //		TaskUtility.PropagateFaultedStates(t);
            //		_remoteTags.Remove(tag.Name);
            //		tag.MarkAsDeleted();
            //		InvokeTagDeleted(tag);
            //	},
            //	cancellationToken,
            //	TaskContinuationOptions.ExecuteSynchronously,
            //	TaskScheduler.Default);
        }
Пример #2
0
        private void InvokeTagCreated(RemoteRepositoryTag tag)
        {
            var handler = TagCreated;

            if (handler != null)
            {
                handler(this, new RemoteReferenceEventArgs(tag));
            }
        }
Пример #3
0
        internal void RemoveTag(RemoteRepositoryTag tag)
        {
            Verify.Argument.IsNotNull(tag, nameof(tag));
            Verify.Argument.IsFalse(tag.IsDeleted, nameof(tag),
                                    Resources.ExcSuppliedObjectIsDeleted.UseAsFormat("tag"));

            var parameters = GetRemoveRemoteReferenceParameters(tag);

            Remote.Repository.Accessor.RemoveRemoteReferences.Invoke(parameters);

            _remoteTags.Remove(tag.Name);
            tag.MarkAsDeleted();
            InvokeTagDeleted(tag);
        }
Пример #4
0
 private void InvokeTagCreated(RemoteRepositoryTag tag)
 => TagCreated?.Invoke(this, new RemoteReferenceEventArgs(tag));
Пример #5
0
        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);
                }
            }
        }