8
8
"net/url"
9
9
)
10
10
11
- //
12
- //
11
+ // @see https://gitlab.com/gitlab-org/gitlab-ce/blob/8-5-stable/doc/api/projects.md#list-projects
12
+ // https://docs.gitlab.com/ee/api/projects.html#list-projects
13
13
//
14
14
func (c * Client ) GetProjectList () ([]* Project , error ) {
15
15
@@ -32,12 +32,12 @@ func (c *Client) GetProjectList() ([]*Project, error) {
32
32
return projectList , nil
33
33
}
34
34
35
- //
36
- //
35
+ // @see https://gitlab.com/gitlab-org/gitlab-ce/blob/8-5-stable/doc/api/projects.md#get-single-project
36
+ // @see https://docs.gitlab.com/ee/api/projects.html#get-single-project
37
37
//
38
38
func (c * Client ) GetProjectById (projectId int ) (* Project , error ) {
39
-
40
39
endpoint := fmt .Sprintf ("projects/%d" , projectId )
40
+
41
41
pageList , err := c .executeAPIMethod (endpoint )
42
42
if err != nil {
43
43
return nil , err
@@ -55,19 +55,18 @@ func (c *Client) GetProjectById(projectId int) (*Project, error) {
55
55
return result , nil
56
56
}
57
57
58
- //
59
- //
58
+ // @see https://gitlab.com/gitlab-org/gitlab-ce/blob/8-5-stable/doc/api/tags.md#list-project-repository-tags
59
+ // @see https://docs.gitlab.com/ee/api/tags.html#list-project-repository-tags
60
60
//
61
61
func (c * Client ) GetTagList (project * Project ) ([]* Tag , error ) {
62
-
63
62
endpoint := fmt .Sprintf ("projects/%d/repository/tags" , project .ID )
63
+
64
64
pageList , err := c .executeAPIMethod (endpoint )
65
65
if err != nil {
66
66
return nil , err
67
67
}
68
68
69
69
tagList := make ([]* Tag , 0 )
70
-
71
70
for _ , body := range pageList {
72
71
page := make ([]* Tag , 0 )
73
72
if err := json .Unmarshal (body , & page ); err != nil {
@@ -80,38 +79,35 @@ func (c *Client) GetTagList(project *Project) ([]*Tag, error) {
80
79
return tagList , nil
81
80
}
82
81
83
- //
84
- //
82
+ // @see https://gitlab.com/gitlab-org/gitlab-ce/blob/8-5-stable/doc/api/repositories.md#get-file-archive
83
+ // @see https://docs.gitlab.com/ee/api/repositories.html#get-file-archive
85
84
//
86
85
func (c * Client ) GetArchive (project * Project , ref string ) ([]byte , error ) {
87
- // v4 uses sha as parameter name
88
- // v3 uses ref as parameter name
89
- refParam := "ref"
90
- if c .HasV4Support {
91
- refParam = "sha"
92
- }
93
-
94
86
endpoint := fmt .Sprintf (
95
- "projects/%d/repository/archive.tar.gz?%s =%s" ,
87
+ "projects/%d/repository/archive.tar.gz?sha =%s" ,
96
88
project .ID ,
97
- refParam ,
98
89
url .QueryEscape (ref ),
99
90
)
100
91
101
92
pageList , err := c .executeAPIMethod (endpoint )
102
93
if err != nil {
103
94
return nil , err
104
95
}
105
-
106
96
if len (pageList ) == 0 {
107
97
return nil , errors .New ("Archive operation failed" )
108
98
}
109
99
110
100
return pageList [0 ], nil
111
101
}
112
102
103
+ // @see https://gitlab.com/gitlab-org/gitlab-ce/blob/8-5-stable/doc/api/repository_files.md#get-file-from-repository
104
+ // for v3 file_path should be QueryString parameter.
113
105
//
106
+ // @see https://docs.gitlab.com/ee/api/repository_files.html#get-file-from-repository
107
+ // for v4 file_path is not a parameter but part of URI. Should be encoded anyway.
108
+ // update, right now this one doesn't seem's to work.
114
109
//
110
+ // KEEP EYE ON THIS METHOD, v4 right now doesn't work as expected.
115
111
//
116
112
func (c * Client ) GetFile (project * Project , path , ref string ) ([]byte , error ) {
117
113
0 commit comments