예제 #1
0
        private async Task <bool> IsRemoteRepoExists()
        {
            if (!string.IsNullOrEmpty(_gitHelperData.lastGitProfile.projectKey) && !string.IsNullOrEmpty(_gitHelperData.lastRepositoryData.repositorySlugName))
            {
                WriteLog("Trying to get repository...");
                //Task<Repository> remoteRepo;
                try
                {
                    /*remoteRepo = _bitbucketClient.GetProjectRepositoryAsync(_gitHelperData.lastGitProfile.projectKey, _gitHelperData.lastRepositoryData.repositorySlugName);
                     * remoteRepo = new Task<Repository>(() =>
                     * {
                     *  _bitbucketClient.GetProjectRepositoryAsync(_gitHelperData.lastGitProfile.projectKey,
                     *      _gitHelperData.lastRepositoryData.repositorySlugName);
                     *
                     *  return null;
                     * });
                     * remoteRepo.Start();
                     * await remoteRepo;*/

                    var repo = await _bitbucketClient.GetProjectRepositoryAsync(_gitHelperData.lastGitProfile.projectKey,
                                                                                _gitHelperData.lastRepositoryData.repositorySlugName);

                    return(!(repo is null));
                }
                catch (Exception e)
                {
                    WriteLog("Can`t check repository...");
                    WriteLog(e.Message);
                    return(false);
                }

                /*Stopwatch stopwatch = Stopwatch.StartNew();
                 * while (!remoteRepo.IsCompleted)
                 * {
                 *  if (stopwatch.ElapsedMilliseconds < 10000)
                 *  {
                 *      await Task.Yield();
                 *  }
                 *  else
                 *  {
                 *      stopwatch.Stop();
                 *      WriteLog("Can`t check repo / waiting time is out");
                 *      break;
                 *  }
                 * }
                 *
                 * return !(remoteRepo.Result is null);*/
            }
            else
            {
                WriteLog("Can`t check remote repository. Repository name or slug name is empty");
                return(false);
            }
        }