本文整理汇总了Golang中github.com/kyokomi/go-gitlab-client/gogitlab.Gitlab类的典型用法代码示例。如果您正苦于以下问题:Golang Gitlab类的具体用法?Golang Gitlab怎么用?Golang Gitlab使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Gitlab类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getProjectIssues
func getProjectIssues(gitlab *gogitlab.Gitlab, projectId int) {
events := gitlab.ProjectEvents(projectId)
for _, event := range events {
var iconName string
switch event.TargetType {
case "Issue":
iconName = ":beer:"
default:
iconName = ":punch:"
}
//fmt.Printf("ProjectID[%d] action[%s] targetId[%d] targetType[%s] targetTitle[%s]\n", event.ProductId, event.ActionName,event.TargetId, event.TargetType, event.TargetTitle)
if event.TargetId != 0 {
actionText := color.Sprintf("@y[%s]", event.ActionName)
repositoriesText := color.Sprintf("@c%s(%d)", event.TargetType, event.TargetId)
userText := color.Sprintf("@c%s", event.Data.UserName)
titleText := color.Sprintf("@g%s", event.TargetTitle)
emoji.Println("@{"+iconName+"}", actionText, repositoriesText, userText, titleText)
} else if event.TargetId == 0 {
actionText := color.Sprintf("@y[%s]", event.ActionName)
repositoriesText := color.Sprintf("@c%s", event.Data.Repository.Name)
userText := color.Sprintf("@c%s", event.Data.UserName)
var titleText string
if event.Data.TotalCommitsCount > 0 {
commitMessage := event.Data.Commits[0].Message
commitMessage = strings.Replace(commitMessage, "\n\n", "\t", -1)
titleText = color.Sprintf("@g%s", commitMessage)
} else if event.Data.Before == "0000000000000000000000000000000000000000" {
titleText = color.Sprintf("@g%s %s", emoji.Sprint("@{:fire:}"), "create New branch")
}
emoji.Println("@{"+iconName+"}", actionText, repositoriesText, userText, titleText)
// fmt.Println(" \t user -> ", event.Data.UserName, event.Data.UserId)
// fmt.Println(" \t author -> ", event.Data.AuthorId)
//
// fmt.Println(" \t\t name -> ", event.Data.Repository.Name)
// fmt.Println(" \t\t description -> ", event.Data.Repository.Description)
// fmt.Println(" \t\t gitUrl -> ", event.Data.Repository.GitUrl)
// fmt.Println(" \t\t pageUrl -> ", event.Data.Repository.PageUrl)
//
// fmt.Println(" \t\t totalCount -> ", event.Data.TotalCommitsCount)
//
// if event.Data.TotalCommitsCount > 0 {
// fmt.Println(" \t\t message -> ", event.Data.Commits[0].Message)
// fmt.Println(" \t\t time -> ", event.Data.Commits[0].Timestamp)
// }
}
}
//
// for _, event := range events {
//
// }
}
开发者ID:kyokomi,项目名称:go-gitlab-notifer,代码行数:57,代码来源:go-gitlab-notifer.go
示例2: GetProjectName
func GetProjectName(gitlab *gogitlab.Gitlab, projectId int) (string, error) {
project, err := gitlab.Project(strconv.Itoa(projectId))
if err != nil {
return "", err
}
return project.Name, nil
}
开发者ID:kyokomi,项目名称:slack-webhock,代码行数:7,代码来源:gitlab.go
示例3: GetMilestoneTitle
// /projects/:id/milestones/:milestone_id
func GetMilestoneTitle(gitlab *gogitlab.Gitlab, projectId, milestoneId int) (string, error) {
milestone, err := gitlab.ProjectMilestone(strconv.Itoa(projectId), strconv.Itoa(milestoneId))
if err != nil {
return "", err
}
return milestone.Title, nil
}
开发者ID:kyokomi,项目名称:slack-webhock,代码行数:8,代码来源:gitlab.go
示例4: GetUserName
func GetUserName(gitlab *gogitlab.Gitlab, userId int) (string, error) {
user, err := gitlab.User(strconv.Itoa(userId))
if err != nil {
return "", err
}
return user.Name, nil
}
开发者ID:kyokomi,项目名称:slack-webhock,代码行数:7,代码来源:gitlab.go
示例5: printGitlabIssues
// 自分のIssueを取得して一覧表示する
func printGitlabIssues(gitlab *gogitlab.Gitlab) {
issues, err := gitlab.Issues()
if err != nil {
log.Fatal(err.Error())
return
}
for _, issue := range issues {
fmt.Printf("[%4d] [%s]\n", issue.Id, issue.Title)
}
}
开发者ID:kyokomi,项目名称:go-gitlab-notifer,代码行数:13,代码来源:go-gitlab-notifer.go
示例6: printGitlabProjects
// 自分の関わってるプロジェクトを取得して一覧表示する
func printGitlabProjects(gitlab *gogitlab.Gitlab) {
projects, err := gitlab.Projects()
if err != nil {
log.Fatal(err.Error())
return
}
for _, project := range projects {
fmt.Printf("[%4d] [%20s] (%s)\n", project.Id, project.Name, project.HttpRepoUrl)
}
}
开发者ID:kyokomi,项目名称:go-gitlab-notifer,代码行数:13,代码来源:go-gitlab-notifer.go
示例7: printActivity
// Activity(dashboard.atpm)の表示。XMLパースなので情報欠落が辛い感じ。廃止予定
func printActivity(gitlab *gogitlab.Gitlab) {
feed, err := gitlab.Activity()
if err != nil {
log.Fatal(err.Error())
return
}
currentUser, err := gitlab.CurrentUser()
if err != nil {
log.Fatal(err.Error())
return
}
for _, feedCommit := range feed.Entries {
feedCommentText := createFeedCommentText(¤tUser, feedCommit)
fmt.Println(feedCommentText)
}
}
开发者ID:kyokomi,项目名称:go-gitlab-notifer,代码行数:19,代码来源:go-gitlab-notifer.go
示例8: printGitlabProjectIssues
func printGitlabProjectIssues(gitlab *gogitlab.Gitlab, projectId int) {
page := 1
for {
issues, err := gitlab.ProjectIssues(projectId, page)
if err != nil {
log.Fatal(err.Error())
return
}
if len(issues) == 0 {
break
}
for _, issue := range issues {
if issue.State == "closed" {
color.Printf("@r[%4d(%d)] [%s] %s state=%s\n", issue.Id, issue.LocalId, issue.Title, issue.Description, issue.State)
} else {
color.Printf("@g[%4d(%d)] [%s] %s state=%s\n", issue.Id, issue.LocalId, issue.Title, issue.Description, issue.State)
}
}
page++
}
}
开发者ID:kyokomi,项目名称:go-gitlab-notifer,代码行数:24,代码来源:go-gitlab-notifer.go
示例9: tickGitlabActivity
func tickGitlabActivity(gitlab *gogitlab.Gitlab, tickSecond int) {
ch := time.Tick(time.Second * time.Duration(10))
lastedFeed, err := gitlab.Activity()
if err != nil {
log.Fatal(err.Error())
return
}
currentUser, err := gitlab.CurrentUser()
if err != nil {
log.Fatal(err.Error())
return
}
for i := len(lastedFeed.Entries) - 1; i >= 0; i-- {
feedCommentText := createFeedCommentText(¤tUser, lastedFeed.Entries[i])
fmt.Println(feedCommentText)
}
for now := range ch {
emoji.Printf("@{:beer:}[%v] tick \n", now)
feed, err := gitlab.Activity()
if err != nil {
log.Fatal(err.Error())
return
}
for i := len(feed.Entries) - 1; i >= 0; i-- {
feedComment := feed.Entries[i]
if feedComment.Updated.After(lastedFeed.Entries[0].Updated) {
feedCommentText := createFeedShortCommentText(feedComment)
fmt.Println(feedCommentText)
Notifier(feedCommentText, feedComment.Id, feedComment.Summary, "")
}
}
lastedFeed = feed
}
}
开发者ID:kyokomi,项目名称:go-gitlab-notifer,代码行数:42,代码来源:go-gitlab-notifer.go
注:本文中的github.com/kyokomi/go-gitlab-client/gogitlab.Gitlab类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论