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
f35aa05b
Commit
f35aa05b
authored
6 years ago
by
Tulir Asokan
Browse files
Options
Downloads
Patches
Plain Diff
Update go-gitlab version and fix assignee formatting
Fixes #7 Fixes #3
parent
659c93ef
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
commands.go
+21
-8
21 additions, 8 deletions
commands.go
with
21 additions
and
8 deletions
commands.go
+
21
−
8
View file @
f35aa05b
...
...
@@ -157,7 +157,7 @@ func commandDiff(git *gitlab.Client, room *mautrix.Room, sender string, args []s
return
}
diffs
,
_
,
err
:=
git
.
Commits
.
GetCommitDiff
(
args
[
0
],
args
[
1
])
diffs
,
_
,
err
:=
git
.
Commits
.
GetCommitDiff
(
args
[
0
],
args
[
1
]
,
&
gitlab
.
GetCommitDiffOptions
{}
)
if
err
!=
nil
{
room
.
Sendf
(
"An error occurred: %s"
,
err
)
return
...
...
@@ -220,6 +220,23 @@ func commandLog(git *gitlab.Client, room *mautrix.Room, sender string, args []st
room
.
SendHTML
(
buf
.
String
())
}
func
printAssignees
(
buf
*
bytes
.
Buffer
,
issue
*
gitlab
.
Issue
)
{
var
names
[]
string
if
len
(
issue
.
Assignees
)
>
0
{
for
_
,
assignee
:=
range
issue
.
Assignees
[
:
len
(
issue
.
Assignees
)
-
1
]
{
names
=
append
(
names
,
assignee
.
Name
)
}
}
else
if
len
(
issue
.
Assignee
.
Name
)
>
0
{
names
=
append
(
names
,
issue
.
Assignee
.
Name
)
}
if
len
(
names
)
==
1
{
fmt
.
Fprintf
(
buf
,
"Assigned to %s."
,
names
[
0
])
}
else
if
len
(
names
)
>
1
{
fmt
.
Fprintf
(
buf
,
"Assigned to %s and %s."
,
strings
.
Join
(
names
[
:
len
(
names
)
-
1
],
", "
),
names
[
len
(
names
)
-
1
])
}
}
func
commandReadIssue
(
git
*
gitlab
.
Client
,
room
*
mautrix
.
Room
,
sender
string
,
args
[]
string
,
lines
[]
string
)
{
if
len
(
args
)
<
2
{
room
.
Send
(
"Usage: !gitlab issue read <repo> <issue id>"
)
...
...
@@ -240,9 +257,7 @@ func commandReadIssue(git *gitlab.Client, room *mautrix.Room, sender string, arg
var
buf
bytes
.
Buffer
fmt
.
Fprintf
(
&
buf
,
"Issue #%[2]d by %[3]s: <a href='%[1]s'>%[4]s</a>."
,
issue
.
WebURL
,
issue
.
IID
,
issue
.
Author
.
Name
,
issue
.
Title
)
if
len
(
issue
.
Assignee
.
Name
)
>
0
{
fmt
.
Fprintf
(
&
buf
,
" Assigned to %s."
,
issue
.
Assignee
.
Name
)
}
printAssignees
(
&
buf
,
issue
)
fmt
.
Fprintf
(
&
buf
,
"<br/>
\n
<blockquote>%s</blockquote><br/>
\n
"
,
strings
.
Replace
(
issue
.
Description
,
"
\n
"
,
"<br/>
\n
"
,
-
1
))
room
.
SendHTML
(
buf
.
String
())
}
...
...
@@ -308,10 +323,8 @@ func commandReadIssueComments(git *gitlab.Client, room *mautrix.Room, sender str
}
comments
,
resp
,
err
:=
git
.
Notes
.
ListIssueNotes
(
args
[
0
],
issueID
,
&
gitlab
.
ListIssueNotesOptions
{
ListOptions
:
gitlab
.
ListOptions
{
Page
:
page
,
PerPage
:
n
,
},
Page
:
page
,
PerPage
:
n
,
})
if
resp
.
StatusCode
==
404
{
room
.
Sendf
(
"Issue #%d or repository %s not found."
,
issueID
,
args
[
0
])
...
...
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