10

I sent this by email to FC support, and it was requested that I post the request here :-)

I'm working on a HipChat bot to do some basic tasks to make things easier. We've automated a lot of our deployment, but currently we still perform some manual steps when we want to deploy tip:

  • Check whether any changesets between the Stage tag and the tip tag are missing code reviews.
  • Check whether any changesets between the Stage tag and the tip tag have code reviews that have not been approved (eg. rejected or outstanding)
  • hg stage + hg push

This then kicks off our CI build, which compiles, runs tests, FTPs to the staging server, etc.

I would like to make this a single command, however using the Kiln API I believe I'd currently have to:

  • Use the History API to fetch the first 100 changesets from the Stage tag (it's possible I'd need to look up the revision ID first, unless revOldest can be a tag)
  • If there are 100 changesets, send the latest ID as the revOldest again to the History API
  • (repeat until we have all changesets since the Stage tag)
  • Enumerate the changesets checking whether there are review IDs against them (if not, abort deployment)
  • Fetch all of the reviews we've collected IDs for, and check whether they've been approved (if not, abort deployment)

This is a little clumsy, and potentially requires a lot of requests. It could be made really simple if there was a way of filtering the History/Changesets based on review status:

  • Fetch all changesets since revOldest that do not have approved reviews

If this was possible, even the 100 limit wouldn't be an issue, because if there are more than 100 changesets, it's probably acceptable to just spit them out for now!

Even a count would do, though ideally I'd like the bot to sent messages to the authors of the changesets informing them they haven't been reviewed (or the person a review is assigned to, telling them it needs completing!).

flag

2 Answers

1

Thanks for the feature request! We'll file it as an official request when it reaches our top 100 feature requests by votes. To get it there, vote up this question!

link|flag
0

I managed to make this work:

https://bitbucket.org/DanTup/fogsharp/src/tip/FogSharp.Samples/UnreviewedChangesets.cs

Unfortunately, it's incredibly slow for a large number of changesets with reviews, as it has to fetch the review to check the status ([I've submitted a feature request to fix this here, please vote][1]!), which means one HTTP request per review, in addition to the one HTTP request per 100 changesets.

using System;
using Xunit;

namespace DanTup.FogSharp.Samples
{
        public class UnreviewedChangesets : Sample
        {
                [Fact]
                public void GetChangesetsWithoutApprovedReviews()
                {
                        // This handles paging automatically, up to maxChangesets (starting at sinceChangeset)
                        foreach (var changeset in kiln.GetHistory(199, sinceChangeset: 4000, maxChangesets: 10))
                        {
                                // Handle changeset with no reviews.
                                if (changeset.ReviewIDs == null || changeset.ReviewIDs.Length == 0)
                                {
                                        Console.WriteLine("No review: {0}, {1}", changeset.Author, changeset.Description);
                                        continue;
                                }

                                // If there are reviews, we need to check if any are not approved. Can't
                                // currently do this in batch, so this is really inefficient :-(
                                foreach (var reviewID in changeset.ReviewIDs)
                                {
                                        var review = kiln.GetReview(reviewID);

                                        if (review.Status != "approved")
                                                Console.WriteLine("Unapproved review: {0}, {1}", changeset.Author, changeset.Description);
                                }
                        }
                }
        }
}
link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.