Index: trunk/tools/gerrit-dippybird/dippy-bird.php |
— | — | @@ -44,7 +44,7 @@ |
45 | 45 | // 'approve' => 'executeApprove', |
46 | 46 | // 'verify' => 'executeVerify', |
47 | 47 | 'submit' => 'executeSubmit', |
48 | | - // 'abandon' => 'executeAbandon', |
| 48 | + 'abandon' => 'executeAbandon', |
49 | 49 | ); |
50 | 50 | |
51 | 51 | public function __construct() { |
— | — | @@ -55,6 +55,12 @@ |
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
| 59 | + /** |
| 60 | + * Execution method |
| 61 | + * |
| 62 | + * Performs sanity check, execute specific gerrit query, then performs |
| 63 | + * specified action. |
| 64 | + */ |
59 | 65 | public function dip() { |
60 | 66 | $this->handleOpts(); |
61 | 67 | if ( !$this->isConfigSane() ) { |
— | — | @@ -79,6 +85,7 @@ |
80 | 86 | } |
81 | 87 | |
82 | 88 | /** |
| 89 | + * Execute specified gerrit query |
83 | 90 | * @return array |
84 | 91 | */ |
85 | 92 | public function executeQuery() { |
— | — | @@ -103,15 +110,34 @@ |
104 | 111 | } |
105 | 112 | |
106 | 113 | /** |
| 114 | + * Execute gerrit review --submit to review and submit patchsets |
107 | 115 | * @param array $results |
108 | | - * @return mixed |
109 | 116 | */ |
110 | 117 | public function executeSubmit( $results ) { |
111 | | - $review_opts = '--verified 1 --code-review 2'; |
| 118 | + $review_opts = '--verified=+1 --code-review=+2'; |
112 | 119 | $action = 'submit'; |
113 | 120 | $this->gerritReviewWrapper( $results, $action, $review_opts ); |
114 | 121 | } |
115 | 122 | |
| 123 | + /** |
| 124 | + * Execute gerrit review --abandon to abandon patchsets |
| 125 | + * @param array $results |
| 126 | + */ |
| 127 | + public function executeAbandon( $results ) { |
| 128 | + $action = 'abandon'; |
| 129 | + $this->gerritReviewWrapper( $results, $action ); |
| 130 | + } |
| 131 | + |
| 132 | + /** |
| 133 | + * A wrapper around the 'gerrit review' command |
| 134 | + * |
| 135 | + * Given a set of results from a gerrit query, perform one of the available |
| 136 | + * gerrit review actions |
| 137 | + * @see $this->validActions |
| 138 | + * @param array $results |
| 139 | + * @param string $action |
| 140 | + * @param string $review_opts |
| 141 | + */ |
116 | 142 | protected function gerritReviewWrapper( $results, $action, $review_opts = '' ) { |
117 | 143 | // If there are less than two items in the array, there are no changesets on which to operate |
118 | 144 | if ( count( $results ) < 2 ) { |