Skip to content
This repository has been archived by the owner on Oct 3, 2018. It is now read-only.

Commit

Permalink
commit comments example
Browse files Browse the repository at this point in the history
  • Loading branch information
kpacha committed Aug 16, 2015
1 parent 63b7b02 commit 652f70a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
32 changes: 30 additions & 2 deletions examples/repositories/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,19 @@ func main() {
" > branches\n"+
" > branch\n"+
" > tags\n"+
" > commits")
" > commits\n"+
" > commit_comments -sha COMMIT_SHA\n"+
" > comment_a_commit -sha COMMIT_SHA -comment COMMENT_BODY")

var id string
flag.StringVar(&id, "id", "", "Specify repository id")

var sha string
flag.StringVar(&sha, "sha", "", "Specify commit sha")

var comment string
flag.StringVar(&comment, "comment", "", "The body of the new comment")

flag.Usage = func() {
fmt.Printf("Usage:\n")
flag.PrintDefaults()
Expand Down Expand Up @@ -90,7 +98,27 @@ func main() {
}

for _, commit := range commits {
fmt.Printf("%s > [%s] %s\n", commit.CreatedAt.Format("Mon 02 Jan 15:04"), commit.Author_Name, commit.Title)
fmt.Printf("(%s) %s > [%s] %s\n", commit.Id, commit.CreatedAt.Format("Mon 02 Jan 15:04"), commit.Author_Name, commit.Title)
}
case "commit_comments":
fmt.Println("Fetching comments on a repository commit…")

comments, err := gitlab.RepoCommitComments(id, sha)
if err != nil {
fmt.Println(err.Error())
}

for _, c := range comments {
fmt.Printf("[%s] %s\n", c.Author.Username, c.Note)
}
case "comment_a_commit":
fmt.Println("Sending a new comment on a repository commit…")

c, err := gitlab.SendRepoCommitComment(id, sha, comment)
if err != nil {
fmt.Println(err.Error())
}

fmt.Printf("[%s] %s\n", c.Author.Username, c.Note)
}
}
4 changes: 2 additions & 2 deletions repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Get a list of comments in a repository commit.
Parameters:
id The ID of a project
id The ID of a project
sha The sha of the commit
Usage:
Expand Down Expand Up @@ -246,7 +246,7 @@ Create a comment in a repository commit.
Parameters:
id The ID of a project
id The ID of a project
sha The sha of the commit
body The body of the comment
Expand Down

0 comments on commit 652f70a

Please sign in to comment.