blob: fe901c40a413d49893ad9b25e33e745d321ffde5 [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// whereiscl is a command-line utility that answers "Where is my CL?".
// Given a Gerrit review URL, it will answer
// - Whether the CL was merged (or abandoned)
// - Whether the CL passed Global Integration (if merged)
package main
import (
func init() {
flag.Usage = func() {
fmt.Fprintf(flag.CommandLine.Output(), `Usage: whereiscl <review URL>
Answers whether a CL is merged (or abandoned) and whether it passed Global Integration.
Review URL can be various review URL forms as below. It can also be a raw CL number or a Change-Id.
$ whereiscl
$ whereiscl
$ whereiscl
$ whereiscl http://fxr/123456789
$ whereiscl http://fxr/Ie8dddbce1eeb01a561f3b36e1685f4136fb61378
$ whereiscl fxr/123456789/some/file
$ whereiscl 123456789
$ whereiscl Ie8dddbce1eeb01a561f3b36e1685f4136fb61378
func main() {
if flag.NArg() == 0 {
// TODO: Consider alternatives. E.g., show all outstanding CLs
// of the current user, or show all CLs that are pending in
// Global Integration.
queryInfo, err := lib.ParseReviewURL(flag.Arg(0))
if err != nil {
log.Fatalf("Error parsing the review URL: %v", err)
ci, err := lib.GetChangeInfo(queryInfo)
if err != nil {
log.Fatalf("Error getting change info: %v", err)
fmt.Printf("CL status: %v\n", ci.Status)
if ci.Status != lib.CLStatusMerged {
gs, err := lib.GetGIStatus(ci)
if err != nil {
log.Fatalf("Error getting GI status: %v", err)
fmt.Printf("GI status: %v\n", gs)