Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
go-gitlab
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
go-gitlab
Commits
7ef3a0e1
Commit
7ef3a0e1
authored
Oct 31, 2017
by
Sander van Harmelen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a small issue with the `ListUserProjects`
A user can be either an ID or a name.
parent
a5ba2c86
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
27 deletions
+28
-27
README.md
README.md
+15
-15
gitlab.go
gitlab.go
+5
-9
projects.go
projects.go
+8
-3
No files found.
README.md
View file @
7ef3a0e1
...
...
@@ -16,29 +16,29 @@ incompatible changes that were needed to fully support the V4 Gitlab API.
This API client package covers
**100%**
of the existing GitLab API calls! So this
includes all calls to the following services:
-
[
x
]
Users
-
[
x
]
Session
-
[
x
]
Projects (including setting Webhooks)
-
[
x
]
Project Snippets
-
[
x
]
Services
-
[
x
]
Repositories
-
[
x
]
Repository Files
-
[
x
]
Commits
-
[
x
]
Branches
-
[
x
]
Merge Requests
-
[
x
]
Commits
-
[
x
]
Deploy Keys
-
[
x
]
Environments
-
[
x
]
Groups
-
[
x
]
Issues
-
[
x
]
Labels
-
[
x
]
Merge Requests
-
[
x
]
Milestones
-
[
x
]
Notes (comments)
-
[
x
]
Deploy Keys
-
[
x
]
System Hooks
-
[
x
]
Groups
-
[
x
]
Namespaces
-
[
x
]
Settings
-
[
x
]
Notes (comments)
-
[
x
]
Pipelines
-
[
x
]
Project Snippets
-
[
x
]
Projects (including setting Webhooks)
-
[
x
]
Repositories
-
[
x
]
Repository Files
-
[
x
]
Services
-
[
x
]
Session
-
[
x
]
Settings
-
[
x
]
System Hooks
-
[
x
]
Users
-
[
x
]
Version
-
[
x
]
Wikis
-
[
x
]
Environments
## Usage
...
...
gitlab.go
View file @
7ef3a0e1
...
...
@@ -551,16 +551,12 @@ type OptionFunc func(*http.Request) error
// WithSudo takes either a username or user ID and sets the SUDO request header
func
WithSudo
(
uid
interface
{})
OptionFunc
{
return
func
(
req
*
http
.
Request
)
error
{
switch
uid
:=
uid
.
(
type
)
{
case
int
:
req
.
Header
.
Set
(
"SUDO"
,
strconv
.
Itoa
(
uid
))
return
nil
case
string
:
req
.
Header
.
Set
(
"SUDO"
,
uid
)
return
nil
default
:
return
fmt
.
Errorf
(
"uid must be either a username or user ID"
)
user
,
err
:=
parseID
(
uid
)
if
err
!=
nil
{
return
err
}
req
.
Header
.
Set
(
"SUDO"
,
user
)
return
nil
}
}
...
...
projects.go
View file @
7ef3a0e1
...
...
@@ -199,10 +199,15 @@ func (s *ProjectsService) ListProjects(opt *ListProjectsOptions, options ...Opti
// ListUserProjects gets a list of projects for the given user.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/projects.html#list-user-projects
func
(
s
*
ProjectsService
)
ListUserProjects
(
user
int
,
opt
*
ListProjectsOptions
,
options
...
OptionFunc
)
([]
*
Project
,
*
Response
,
error
)
{
// GitLab API docs:
// https://docs.gitlab.com/ce/api/projects.html#list-user-projects
func
(
s
*
ProjectsService
)
ListUserProjects
(
uid
interface
{},
opt
*
ListProjectsOptions
,
options
...
OptionFunc
)
([]
*
Project
,
*
Response
,
error
)
{
user
,
err
:=
parseID
(
uid
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"users/%s/projects"
,
user
)
u
:=
fmt
.
Sprintf
(
"users/%d/projects"
,
user
)
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
opt
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
err
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment