Ejemplo n.º 1
0
 private static Task PushAsync(Repository repository, PushParameters parameters, IProgress<OperationProgress> progress, CancellationToken cancellationToken)
 {
     var notificationsBlock = repository.Monitor.BlockNotifications(RepositoryNotifications.BranchChanged);
     return repository.Accessor
                      .Push.InvokeAsync(parameters, progress, cancellationToken)
                      .ContinueWith(task =>
                         {
                             notificationsBlock.Dispose();
                             var res = TaskUtility.UnwrapResult(task);
                             bool changed = false;
                             for(int i = 0; i < res.Count; ++i)
                             {
                                 if(res[i].Type != PushResultType.UpToDate && res[i].Type != PushResultType.Rejected)
                                 {
                                     changed = true;
                                     break;
                                 }
                             }
                             if(changed)
                             {
                                 repository.Refs.Remotes.Refresh();
                             }
                         },
                         cancellationToken);
 }
Ejemplo n.º 2
0
 private static PushParameters GetPushParameters(string remoteRepository, ICollection<Branch> branches, bool forceOverwrite, bool thinPack, bool sendTags)
 {
     var names = new List<string>(branches.Count);
     foreach(var branch in branches)
     {
         names.Add(branch.Name);
     }
     var parameters = new PushParameters
     {
         Repository	= remoteRepository,
         PushMode	= sendTags ? PushMode.Tags : PushMode.Default,
         Force		= forceOverwrite,
         ThinPack	= thinPack,
         Refspecs	= names,
     };
     return parameters;
 }