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
cc2f9f2f
Commit
cc2f9f2f
authored
7 years ago
by
Tulir Asokan
Browse files
Options
Downloads
Patches
Plain Diff
Add support for commenting on issues
parent
d9e22b8a
No related branches found
No related tags found
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
+23
-0
23 additions, 0 deletions
commands.go
with
24 additions
and
1 deletion
README.md
+
1
−
1
View file @
cc2f9f2f
...
@@ -16,7 +16,7 @@ A Gitlab bot for Matrix. It uses
...
@@ -16,7 +16,7 @@ A Gitlab bot for Matrix. It uses
*
[x] Read issues
*
[x] Read issues
*
[x] Create/close/reopen issues
*
[x] Create/close/reopen issues
*
[ ] Read comments on issues
*
[ ] Read comments on issues
*
[
] Comment on issues
*
[
x
] Comment on issues
## Usage
## Usage
Configure the server by copying
`example-config.json`
to
`config.json`
and
Configure the server by copying
`example-config.json`
to
`config.json`
and
...
...
This diff is collapsed.
Click to expand it.
commands.go
+
23
−
0
View file @
cc2f9f2f
...
@@ -265,6 +265,28 @@ func commandCreateIssue(git *gitlab.Client, room *mautrix.Room, sender string, a
...
@@ -265,6 +265,28 @@ func commandCreateIssue(git *gitlab.Client, room *mautrix.Room, sender string, a
}
}
}
}
func
commandCommentOnIssue
(
git
*
gitlab
.
Client
,
room
*
mautrix
.
Room
,
sender
string
,
args
[]
string
,
lines
[]
string
)
{
if
len
(
args
)
<
2
{
room
.
Send
(
"Usage: !gitlab issue comment <repo> <issue id> [
\\
n] <body>"
)
return
}
issueID
,
err
:=
strconv
.
Atoi
(
args
[
1
])
if
err
!=
nil
{
room
.
Sendf
(
"Invalid issue ID: %s"
,
args
[
1
])
}
var
body
string
if
len
(
args
)
>
2
{
body
=
strings
.
Join
(
args
[
2
:
],
" "
)
+
"
\n
"
}
body
+=
strings
.
Join
(
lines
,
"
\n
"
)
git
.
Notes
.
CreateIssueNote
(
args
[
0
],
issueID
,
&
gitlab
.
CreateIssueNoteOptions
{
Body
:
&
body
,
})
}
func
commandIssue
(
git
*
gitlab
.
Client
,
room
*
mautrix
.
Room
,
sender
string
,
args
[]
string
,
lines
[]
string
)
{
func
commandIssue
(
git
*
gitlab
.
Client
,
room
*
mautrix
.
Room
,
sender
string
,
args
[]
string
,
lines
[]
string
)
{
if
len
(
args
)
==
0
{
if
len
(
args
)
==
0
{
room
.
SendHTML
(
"Unknown subcommand. Try <code>!gitlab help issue</code> for help."
)
room
.
SendHTML
(
"Unknown subcommand. Try <code>!gitlab help issue</code> for help."
)
...
@@ -310,6 +332,7 @@ func commandIssue(git *gitlab.Client, room *mautrix.Room, sender string, args []
...
@@ -310,6 +332,7 @@ func commandIssue(git *gitlab.Client, room *mautrix.Room, sender string, args []
room
.
Sendf
(
"Failed to %s issue: %s"
,
subcommand
,
err
)
room
.
Sendf
(
"Failed to %s issue: %s"
,
subcommand
,
err
)
}
}
case
"comment"
:
case
"comment"
:
commandCommentOnIssue
(
git
,
room
,
sender
,
args
,
lines
)
case
"read-comments"
:
case
"read-comments"
:
default
:
default
:
room
.
SendHTML
(
"Unknown subcommand. Try <code>!gitlab help issue</code> for help."
)
room
.
SendHTML
(
"Unknown subcommand. Try <code>!gitlab help issue</code> for help."
)
...
...
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