{"id":9785,"date":"2014-09-17T17:46:31","date_gmt":"2014-09-18T00:46:31","guid":{"rendered":"http:\/\/princessleia.com\/journal\/?p=9785"},"modified":"2016-11-03T10:21:02","modified_gmt":"2016-11-03T17:21:02","slug":"offline-cli-based-gerrit-code-review-with-gertty","status":"publish","type":"post","link":"https:\/\/princessleia.com\/journal\/2014\/09\/offline-cli-based-gerrit-code-review-with-gertty\/","title":{"rendered":"Offline, CLI-based Gerrit code review with Gertty"},"content":{"rendered":"<p>This past week I headed to Florida to present at <a href=\"http:\/\/fossetcon.org\/\">Fossetcon<\/a> and thought it would be a great opportunity to do a formal review of a new tool <a href=\"http:\/\/lists.openstack.org\/pipermail\/openstack-dev\/2014-September\/045013.html\">recently released<\/a> by the OpenStack Infrastructure team (well, mostly James E. Blair): <a href=\"https:\/\/pypi.python.org\/pypi\/gertty\">Gertty<\/a>.<\/p>\n<p>The <a href=\"https:\/\/pypi.python.org\/pypi\/gertty\">description<\/a> of this tool is as follows:<\/p>\n<p><em>As compared to the web interface, the main advantages are:<\/p>\n<ul>\n<li>Workflow &#8212; the interface is designed to support a workflow similar to reading network news or mail. In particular, it is designed to deal with a large number of review requests across a large number of projects.<\/li>\n<li>Offline Use &#8212; Gertty syncs information about changes in subscribed projects to a local database and local git repos. All review operations are performed against that database and then synced back to Gerrit.<\/li>\n<li>Speed &#8212; user actions modify locally cached content and need not wait for server interaction.<\/li>\n<li>Convenience &#8212; because Gertty downloads all changes to local git repos, a single command instructs it to checkout a change into that repo for detailed examination or testing of larger changes.<\/li>\n<\/ul>\n<p><\/em><\/p>\n<p>For me the two big ones were CLI-based workflow and offline use, I could review patches while on a plane or on terrible hotel wifi!<\/p>\n<p>I highly recommend reading the <a href=\"http:\/\/lists.openstack.org\/pipermail\/openstack-dev\/2014-September\/045013.html\">announcement email<\/a> to learn more about the features, but to get going here&#8217;s a quick rundown for the currently released version 1.0.2:<\/p>\n<p>First, you&#8217;ll need to set a password in Gerrit so you can use the REST API. Do that by logging into Gerrit and going to <a href=\"https:\/\/review.openstack.org\/#\/settings\/http-password\">https:\/\/review.openstack.org\/#\/settings\/http-password<\/a><\/p>\n<p>From there:<\/p>\n<p><code>pip install gertty<\/p>\n<p>wget https:\/\/git.openstack.org\/cgit\/stackforge\/gertty\/plain\/examples\/openstack-gertty.yaml -O ~\/.gertty.yaml<\/code><\/p>\n<p>Edit ~\/.gertty.yaml and update anything that says &#8220;CHANGEME&#8221;<\/p>\n<p>A couple things worthy of note:<\/p>\n<ul>\n<li>Be aware that by default, uses ~\/git\/ for the git-root, I had to change this in my ~\/.gertty.yaml so it didn&#8217;t touch my existing ~\/git\/ directory.<\/li>\n<li>You can also run it in a venv, as described <a href=\"https:\/\/pypi.python.org\/pypi\/gertty\">on the pypi page<\/a>.<\/li>\n<\/ul>\n<p>Now run <code>gertty<\/code> from your terminal!<\/p>\n<p>When you first load it up, you get a welcome screen with some hints on how to use it, including the all important &#8220;press F1 for help&#8221;:<\/p>\n<div align=\"center\"><a href=\"http:\/\/princessleia.com\/images\/journalpics\/092014\/gertty_1.0.2_intro.png\"><img decoding=\"async\" src=\"http:\/\/princessleia.com\/images\/journalpics\/092014\/gertty_1.0.2_intro_sm.png\" alt=\"\" border=\"0\"><\/a><\/div>\n<p>Note: I use xfce4-terminal and F1 is bound to terminal help, see the <a href=\"http:\/\/docs.xfce.org\/faq\">Xfce FAQ<\/a> to learn how to disable this so you can actually read the Gertty help and don&#8217;t have to ask on IRC how to do simple things like I did ;)<\/p>\n<p>As instructed, from here you hit &#8220;L&#8221; to list projects, this is the page where you can subscribe to them:<\/p>\n<div align=\"center\"><a href=\"http:\/\/princessleia.com\/images\/journalpics\/092014\/gertty_1.0.2_project_list.png\"><img decoding=\"async\" src=\"http:\/\/princessleia.com\/images\/journalpics\/092014\/gertty_1.0.2_project_list_sm.png\" alt=\"\" border=\"0\"><\/a><\/div>\n<p>You subscribe to projects by pressing &#8220;s&#8221; and they will show up as bright white, then you can navigate into them to list open reviews:<\/p>\n<div align=\"center\"><a href=\"http:\/\/princessleia.com\/images\/journalpics\/092014\/gertty_1.0.2_reviews.png\"><img decoding=\"async\" src=\"http:\/\/princessleia.com\/images\/journalpics\/092014\/gertty_1.0.2_reviews_sm.png\" alt=\"\" border=\"0\"><\/a><\/div>\n<p>Go to a review you want to look at and hit enter, bringing up the review screen. This should look very familiar, just text only. I&#8217;ve expanded my standard 80&#215;24 terminal window here so you can get a good look at what the full screen looks like:<\/p>\n<div align=\"center\"><a href=\"http:\/\/princessleia.com\/images\/journalpics\/092014\/gertty_1.0.2_review_page.png\"><img decoding=\"async\" src=\"http:\/\/princessleia.com\/images\/journalpics\/092014\/gertty_1.0.2_review_page_sm.png\" alt=\"\" border=\"0\"><\/a><\/div>\n<p>Navigate down to <code>&lt; Diff &gt;<\/code> to see the diff. This is pretty cool, instead of showing it on separate pages like the web UI, it shows you a unified page with all of the file diffs, so you just need to scroll through them to see them all:<\/p>\n<div align=\"center\"><a href=\"http:\/\/princessleia.com\/images\/journalpics\/092014\/gertty_1.0.2_diff.png\"><img decoding=\"async\" src=\"http:\/\/princessleia.com\/images\/journalpics\/092014\/gertty_1.0.2_diff_sm.png\" alt=\"\" border=\"0\"><\/a><\/div>\n<p>Finally, you review! Select <code>&lt; Review &gt;<\/code> back on the main review page and it will pop up a screen that allows you to select your +2, +1, -1, etc and add a message:<\/p>\n<div align=\"center\"><a href=\"http:\/\/princessleia.com\/images\/journalpics\/092014\/gertty_1.0.2_plus_1.png\"><img decoding=\"async\" src=\"http:\/\/princessleia.com\/images\/journalpics\/092014\/gertty_1.0.2_plus_1_sm.png\" alt=\"\" border=\"0\"><\/a><\/div>\n<p>Your reviews are synced along with everything else when Gertty knows it&#8217;s online and can pull down review updates and upload your changes. At any time you can look at the top right of your screen to see how many pending sync requests it has.<\/p>\n<p>When you want to quit, CTRL-q<\/p>\n<p>I highly recommend giving it a spin. Feel free to ask questions about usage in <code>#openstack-infra<\/code> and bugs are tracked in Storyboard here: <a href=\"https:\/\/storyboard.openstack.org\/#!\/project\/698\">https:\/\/storyboard.openstack.org\/#!\/project\/698<\/a>. The code lives in a stackforge repo at: <a href=\"http:\/\/git.openstack.org\/cgit\/stackforge\/gertty\">http:\/\/git.openstack.org\/cgit\/stackforge\/gertty<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This past week I headed to Florida to present at Fossetcon and thought it would be a great opportunity to do a formal review of a new tool recently released by the OpenStack Infrastructure team (well, mostly James E. Blair): Gertty. The description of this tool is as follows: As compared to the web interface, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,37],"tags":[],"class_list":["post-9785","post","type-post","status-publish","format-standard","hentry","category-openstack","category-tech"],"_links":{"self":[{"href":"https:\/\/princessleia.com\/journal\/wp-json\/wp\/v2\/posts\/9785","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/princessleia.com\/journal\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/princessleia.com\/journal\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/princessleia.com\/journal\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/princessleia.com\/journal\/wp-json\/wp\/v2\/comments?post=9785"}],"version-history":[{"count":25,"href":"https:\/\/princessleia.com\/journal\/wp-json\/wp\/v2\/posts\/9785\/revisions"}],"predecessor-version":[{"id":9810,"href":"https:\/\/princessleia.com\/journal\/wp-json\/wp\/v2\/posts\/9785\/revisions\/9810"}],"wp:attachment":[{"href":"https:\/\/princessleia.com\/journal\/wp-json\/wp\/v2\/media?parent=9785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/princessleia.com\/journal\/wp-json\/wp\/v2\/categories?post=9785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/princessleia.com\/journal\/wp-json\/wp\/v2\/tags?post=9785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}