Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gitlab
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
maubot
gitlab
Commits
5ffbf10c
Commit
5ffbf10c
authored
7 years ago
by
Tulir Asokan
Browse files
Options
Downloads
Patches
Plain Diff
Add issue creating/closing/reopening
parent
f1d6d530
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+1
-1
1 addition, 1 deletion
README.md
commands.go
+51
-4
51 additions, 4 deletions
commands.go
with
52 additions
and
5 deletions
README.md
+
1
−
1
View file @
5ffbf10c
...
...
@@ -14,7 +14,7 @@ A Gitlab bot for Matrix. It uses
*
[x] View commit history
*
[ ] Issue management
*
[x] Read issues
*
[
] Create/close/reopen issues
*
[
x
] Create/close/reopen issues
*
[ ] Read comments on issues
*
[ ] Comment on issues
...
...
This diff is collapsed.
Click to expand it.
commands.go
+
51
−
4
View file @
5ffbf10c
...
...
@@ -225,20 +225,31 @@ func commandIssue(git *gitlab.Client, room *mautrix.Room, sender string, args []
return
}
switch
args
[
0
]
{
subcommand
:=
args
[
0
]
if
len
(
args
)
>
1
{
args
=
args
[
1
:
]
}
else
{
args
=
[]
string
{}
}
switch
subcommand
{
case
"show"
:
fallthrough
case
"view"
:
fallthrough
case
"read"
:
if
len
(
args
)
<
3
{
if
len
(
args
)
<
2
{
room
.
Send
(
"Usage: !gitlab issue read <repo> <issue id>"
)
return
}
id
,
err
:=
strconv
.
Atoi
(
args
[
2
])
id
,
err
:=
strconv
.
Atoi
(
args
[
1
])
if
err
!=
nil
{
room
.
Send
(
"Usage: !gitlab issue read <repo> <issue id>"
)
return
}
issue
,
_
,
err
:=
git
.
Issues
.
GetIssue
(
args
[
1
],
id
)
issue
,
_
,
err
:=
git
.
Issues
.
GetIssue
(
args
[
0
],
id
)
if
err
!=
nil
{
room
.
Sendf
(
"An error occurred: %s"
,
err
)
return
...
...
@@ -251,8 +262,44 @@ func commandIssue(git *gitlab.Client, room *mautrix.Room, sender string, args []
}
fmt
.
Fprintf
(
&
buf
,
"<br/>
\n
<blockquote>%s</blockquote><br/>
\n
"
,
strings
.
Replace
(
issue
.
Description
,
"
\n
"
,
"<br/>
\n
"
,
-
1
))
room
.
SendHTML
(
buf
.
String
())
case
"create"
:
fallthrough
case
"open"
:
if
len
(
args
)
<
2
{
room
.
Send
(
"Usage: !gitlab issue open <repo> <title>
\\
n <body>"
)
return
}
title
:=
strings
.
Join
(
args
[
1
:
],
" "
)
description
:=
strings
.
Join
(
lines
,
"
\n
"
)
_
,
_
,
err
:=
git
.
Issues
.
CreateIssue
(
args
[
0
],
&
gitlab
.
CreateIssueOptions
{
Title
:
&
title
,
Description
:
&
description
,
})
if
err
!=
nil
{
room
.
Sendf
(
"Failed to create issue: %s"
,
err
)
}
case
"close"
:
fallthrough
case
"reopen"
:
if
len
(
args
)
<
2
{
room
.
Sendf
(
"Usage: !gitlab issue %s <repo> <issue number>"
,
subcommand
)
return
}
issueID
,
err
:=
strconv
.
Atoi
(
args
[
1
])
if
err
!=
nil
{
room
.
Sendf
(
"Invalid issue ID: %s"
,
args
[
1
])
}
_
,
resp
,
err
:=
git
.
Issues
.
UpdateIssue
(
args
[
0
],
issueID
,
&
gitlab
.
UpdateIssueOptions
{
StateEvent
:
&
subcommand
,
})
if
resp
.
StatusCode
==
404
{
room
.
Sendf
(
"Issue #%d or repository %s not found."
,
issueID
,
args
[
0
])
}
else
if
err
!=
nil
{
room
.
Sendf
(
"Failed to %s issue: %s"
,
subcommand
,
err
)
}
case
"comment"
:
case
"read-comments"
:
default
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment