Skip to content

Instantly share code, notes, and snippets.

@haya14busa
Last active January 30, 2017 00:04
Show Gist options
  • Save haya14busa/0da856ee00536c556b23ebf33ed977af to your computer and use it in GitHub Desktop.
Save haya14busa/0da856ee00536c556b23ebf33ed977af to your computer and use it in GitHub Desktop.
gerrit CommentInput test
package main
import (
"context"
"fmt"
"log"
"golang.org/x/build/gerrit"
)
func main() {
if err := run(); err != nil {
log.Fatal(err)
}
}
func run() error {
fmt.Println("Hello, Gerrit!")
const (
url = "https://review.gerrithub.io"
username = "haya14busa"
password = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
)
// auto := gerrit.NoAuth
auto := gerrit.BasicAuth(username, password)
cli := gerrit.NewClient(url, auto)
ctx := context.Background()
const (
changeID = "345564"
revision = "387b20cdd1798709eaeaa011c9d091704cfe5318"
)
changeInfo, err := cli.GetChangeDetail(ctx, changeID)
if err != nil {
return err
}
for _, m := range changeInfo.Messages {
fmt.Println("---")
fmt.Println(m.Message)
}
review := gerrit.ReviewInput{
Message: "SetReview test!",
Comments: map[string][]gerrit.CommentInput{
"hello.go": []gerrit.CommentInput{
{
Line: 1,
Message: "inline comment test to line 1",
},
{
Line: 2,
Message: "inline comment test to line 2",
},
},
},
}
if err := cli.SetReview(ctx, changeID, revision, review); err != nil {
return err
}
return nil
}
@haya14busa
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment