예제 #1
0
        /// <summary>
        /// Uploads the diff.
        /// </summary>
        /// <param name="reviewRequest">The review request.</param>
        /// <param name="arguments">The arguments.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">arguments</exception>
        /// <exception cref="ReviewBoardAuthenticationException"></exception>
        public async Task UploadDiffAsync(ReviewBoardReviewRequest reviewRequest, ReviewBoardArguments arguments)
        {
            if (reviewRequest == null)
            {
                throw new ArgumentNullException("reviewRequest");
            }
            if (arguments == null)
            {
                throw new ArgumentNullException("arguments");
            }

            if (!Login(arguments))
            {
                throw new ReviewBoardAuthenticationException();
            }

            await AddReviewDiffAsync(reviewRequest.Id, arguments.BaseDirectory, arguments.DiffFile).ConfigureAwait(false);

            reviewRequest.Summary = arguments.Summary;
            reviewRequest.Description = arguments.Description;
            reviewRequest.Groups = arguments.Group;
            reviewRequest.Public = true;
            reviewRequest.BugsClosed = arguments.Bugs;

            await UpdateReviewRequestAsync(reviewRequest).ConfigureAwait(false);
        }
예제 #2
0
        /// <summary>
        /// Uploads the diff.
        /// </summary>
        /// <param name="reviewRequest">The review request.</param>
        /// <param name="arguments">The arguments.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">arguments</exception>
        /// <exception cref="ReviewBoardAuthenticationException"></exception>
        public async Task UploadDiffAsync(ReviewBoardReviewRequest reviewRequest, ReviewBoardArguments arguments)
        {
            if (reviewRequest == null)
            {
                throw new ArgumentNullException("reviewRequest");
            }
            if (arguments == null)
            {
                throw new ArgumentNullException("arguments");
            }

            if (!Login(arguments))
            {
                throw new ReviewBoardAuthenticationException();
            }

            await AddReviewDiffAsync(reviewRequest.Id, arguments.BaseDirectory, arguments.DiffFile).ConfigureAwait(false);

            reviewRequest.Summary     = arguments.Summary;
            reviewRequest.Description = arguments.Description;
            reviewRequest.Groups      = arguments.Group;
            reviewRequest.Public      = true;
            reviewRequest.BugsClosed  = arguments.Bugs;

            await UpdateReviewRequestAsync(reviewRequest).ConfigureAwait(false);
        }
예제 #3
0
        private bool Login(ReviewBoardArguments arguments)
        {
            if (ReadCookies())
            {
                return(true);
            }

            if (arguments.CredentialCallback == null)
            {
                return(false);
            }
            var credentials = arguments.CredentialCallback("Review Board login");

            Client.Authenticator = new HttpBasicAuthenticator(credentials.Username, credentials.Password);
            return(true);
        }
예제 #4
0
        /// <summary>
        /// Posts a new review request to review board.
        /// </summary>
        /// <param name="arguments">The arguments.</param>
        /// <returns>
        /// Response filled with good data.
        /// </returns>
        /// <exception cref="ReviewBoardException">Thrown if the review cannot be posted.</exception>
        public async Task<ReviewBoardResponse> PostToReviewBoardAsync(ReviewBoardArguments arguments)
        {
            if (!Login(arguments))
            {
                throw new ReviewBoardAuthenticationException();
            }

            var reviewRequest = await PostReviewDraftAsync(arguments.Repository).ConfigureAwait(false);
            if (reviewRequest == null)
            {
                throw new ReviewBoardException("Unable to post review!");
            }

            return new ReviewBoardResponse
            {
                ReviewTicketId = reviewRequest.Id.ToString(CultureInfo.InvariantCulture),
                ReviewUrl = _clientUrl + @"r/" + reviewRequest.Id,
                ReviewRequest = reviewRequest
            };
        }
예제 #5
0
        /// <summary>
        /// Posts a new review request to review board.
        /// </summary>
        /// <param name="arguments">The arguments.</param>
        /// <returns>
        /// Response filled with good data.
        /// </returns>
        /// <exception cref="ReviewBoardException">Thrown if the review cannot be posted.</exception>
        public async Task <ReviewBoardResponse> PostToReviewBoardAsync(ReviewBoardArguments arguments)
        {
            if (!Login(arguments))
            {
                throw new ReviewBoardAuthenticationException();
            }

            var reviewRequest = await PostReviewDraftAsync(arguments.Repository).ConfigureAwait(false);

            if (reviewRequest == null)
            {
                throw new ReviewBoardException("Unable to post review!");
            }

            return(new ReviewBoardResponse
            {
                ReviewTicketId = reviewRequest.Id.ToString(CultureInfo.InvariantCulture),
                ReviewUrl = _clientUrl + @"r/" + reviewRequest.Id,
                ReviewRequest = reviewRequest
            });
        }
예제 #6
0
 public async Task<ReviewBoardResponse> PostToReviewBoardAsync(ReviewBoardArguments arguments)
 {
     await Task.Delay(1000);
     arguments.CredentialCallback("Review Board login");
     return new ReviewBoardResponse { ReviewTicketId = "121", ReviewUrl = "http://intra/reviewboard/121/" };
 }
예제 #7
0
 public async Task UploadDiffAsync(ReviewBoardReviewRequest reviewRequest, ReviewBoardArguments arguments)
 {
     await Task.Delay(2000).ConfigureAwait(false);
 }
예제 #8
0
        private bool Login(ReviewBoardArguments arguments)
        {
            if (ReadCookies())
            {
                return true;
            }

            if (arguments.CredentialCallback == null)
            {
                return false;
            }
            var credentials = arguments.CredentialCallback("Review Board login");
            Client.Authenticator = new HttpBasicAuthenticator(credentials.Username, credentials.Password);
            return true;
        }