Last active
January 30, 2017 00:04
-
-
Save haya14busa/0da856ee00536c556b23ebf33ed977af to your computer and use it in GitHub Desktop.
gerrit CommentInput test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
url: https://review.gerrithub.io/#/c/345564/1/hello.go