gitlab 3.7.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.travis.yml +2 -2
  4. data/CHANGELOG.md +24 -0
  5. data/README.md +7 -6
  6. data/gitlab.gemspec +4 -6
  7. data/lib/gitlab/client.rb +24 -0
  8. data/lib/gitlab/client/branches.rb +13 -13
  9. data/lib/gitlab/client/build_triggers.rb +9 -9
  10. data/lib/gitlab/client/build_variables.rb +11 -11
  11. data/lib/gitlab/client/builds.rb +16 -16
  12. data/lib/gitlab/client/commits.rb +39 -14
  13. data/lib/gitlab/client/groups.rb +1 -1
  14. data/lib/gitlab/client/issues.rb +40 -16
  15. data/lib/gitlab/client/labels.rb +9 -9
  16. data/lib/gitlab/client/merge_requests.rb +61 -24
  17. data/lib/gitlab/client/milestones.rb +25 -11
  18. data/lib/gitlab/client/namespaces.rb +2 -1
  19. data/lib/gitlab/client/notes.rb +16 -16
  20. data/lib/gitlab/client/pipelines.rb +68 -0
  21. data/lib/gitlab/client/projects.rb +111 -49
  22. data/lib/gitlab/client/repositories.rb +27 -23
  23. data/lib/gitlab/client/repository_files.rb +29 -10
  24. data/lib/gitlab/client/runners.rb +15 -15
  25. data/lib/gitlab/client/services.rb +8 -6
  26. data/lib/gitlab/client/snippets.rb +13 -13
  27. data/lib/gitlab/client/system_hooks.rb +1 -1
  28. data/lib/gitlab/client/tags.rb +13 -13
  29. data/lib/gitlab/client/users.rb +12 -5
  30. data/lib/gitlab/file_response.rb +1 -0
  31. data/lib/gitlab/version.rb +1 -1
  32. data/spec/fixtures/merge_request_closes_issues.json +1 -0
  33. data/spec/fixtures/milestone_merge_requests.json +1 -0
  34. data/spec/fixtures/pipeline.json +23 -0
  35. data/spec/fixtures/pipeline_cancel.json +23 -0
  36. data/spec/fixtures/pipeline_create.json +23 -0
  37. data/spec/fixtures/pipeline_retry.json +23 -0
  38. data/spec/fixtures/pipelines.json +48 -0
  39. data/spec/fixtures/project_commit_create.json +22 -0
  40. data/spec/fixtures/project_star.json +44 -0
  41. data/spec/fixtures/project_unstar.json +44 -0
  42. data/spec/fixtures/{git_hook.json → push_rule.json} +0 -0
  43. data/spec/gitlab/cli_spec.rb +9 -0
  44. data/spec/gitlab/client/client_spec.rb +11 -0
  45. data/spec/gitlab/client/commits_spec.rb +31 -0
  46. data/spec/gitlab/client/issues_spec.rb +48 -0
  47. data/spec/gitlab/client/merge_requests_spec.rb +57 -10
  48. data/spec/gitlab/client/milestones_spec.rb +16 -0
  49. data/spec/gitlab/client/pipelines_spec.rb +95 -0
  50. data/spec/gitlab/client/projects_spec.rb +116 -38
  51. data/spec/gitlab/client/repositories_spec.rb +0 -15
  52. data/spec/gitlab/client/repository_files_spec.rb +17 -2
  53. data/spec/gitlab/client/users_spec.rb +31 -13
  54. data/spec/gitlab/file_response_spec.rb +6 -1
  55. metadata +53 -43
@@ -1,42 +1,46 @@
1
1
  class Gitlab::Client
2
2
  # Defines methods related to repositories.
3
- # @see https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/repositories.md
3
+ # @see https://docs.gitlab.com/ce/api/repositories.html
4
4
  module Repositories
5
- # Get the contents of a file
6
- #
7
- # @example
8
- # Gitlab.file_contents(42, 'Gemfile')
9
- # Gitlab.repo_file_contents(3, 'Gemfile', 'ed899a2f4b50b4370feeea94676502b42383c746')
10
- #
11
- # @param [Integer] project The ID of a project.
12
- # @param [String] filepath The relative path of the file in the repository
13
- # @param [String] ref The name of a repository branch or tag or if not given the default branch.
14
- # @return [String]
15
- def file_contents(project, filepath, ref='master')
16
- ref = URI.encode(ref, /\W/)
17
- get "/projects/#{project}/repository/blobs/#{ref}?filepath=#{filepath}",
18
- format: nil,
19
- headers: { Accept: 'text/plain' },
20
- parser: ::Gitlab::Request::Parser
21
- end
22
- alias_method :repo_file_contents, :file_contents
23
-
24
5
  # Get file tree project (root level).
25
6
  #
26
7
  # @example
27
8
  # Gitlab.tree(42)
28
9
  # Gitlab.tree(42, { path: 'Gemfile' })
29
10
  #
30
- # @param [Integer] project The ID of a project.
11
+ # @param [Integer, String] project The ID or name of a project.
31
12
  # @param [Hash] options A customizable set of options.
32
13
  # @option options [String] :path The path inside repository.
33
14
  # @option options [String] :ref_name The name of a repository branch or tag.
34
15
  # @return [Gitlab::ObjectifiedHash]
35
16
  def tree(project, options={})
36
- get("/projects/#{project}/repository/tree", query: options)
17
+ get("/projects/#{url_encode project}/repository/tree", query: options)
37
18
  end
38
19
  alias_method :repo_tree, :tree
39
20
 
21
+ # Get project repository archive
22
+ #
23
+ # @example
24
+ # Gitlab.repo_archive(42)
25
+ # Gitlab.repo_archive(42, 'deadbeef')
26
+ #
27
+ # @param [Integer, String] project The ID or name of a project.
28
+ # @param [String] ref The commit sha, branch, or tag to download.
29
+ # @return [Gitlab::FileResponse]
30
+ def repo_archive(project, ref = 'master')
31
+ get("/projects/#{url_encode project}/repository/archive",
32
+ format: nil,
33
+ headers: { Accept: 'application/octet-stream' },
34
+ query: { sha: ref },
35
+ parser: proc { |body, _|
36
+ if body.encoding == Encoding::ASCII_8BIT # binary response
37
+ ::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
38
+ else # error with json response
39
+ ::Gitlab::Request.parse(body)
40
+ end
41
+ })
42
+ end
43
+
40
44
  # Compares branches, tags or commits.
41
45
  #
42
46
  # @example
@@ -48,7 +52,7 @@ class Gitlab::Client
48
52
  # @param [String] to The commit SHA or branch name of to branch.
49
53
  # @return [Gitlab::ObjectifiedHash]
50
54
  def compare(project, from, to)
51
- get("/projects/#{project}/repository/compare", query: { from: from, to: to })
55
+ get("/projects/#{url_encode project}/repository/compare", query: { from: from, to: to })
52
56
  end
53
57
  alias_method :repo_compare, :compare
54
58
  end
@@ -2,20 +2,39 @@ require 'base64'
2
2
 
3
3
  class Gitlab::Client
4
4
  # Defines methods related to repository files.
5
- # @see https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/repository_files.md
5
+ # @see https://docs.gitlab.com/ce/api/repository_files.html
6
6
  module RepositoryFiles
7
+ # Get the contents of a file
8
+ #
9
+ # @example
10
+ # Gitlab.file_contents(42, 'Gemfile')
11
+ # Gitlab.repo_file_contents(3, 'Gemfile', 'ed899a2f4b50b4370feeea94676502b42383c746')
12
+ #
13
+ # @param [Integer, String] project The ID or name of a project.
14
+ # @param [String] filepath The relative path of the file in the repository
15
+ # @param [String] ref The name of a repository branch or tag or if not given the default branch.
16
+ # @return [String]
17
+ def file_contents(project, filepath, ref='master')
18
+ ref = URI.encode(ref, /\W/)
19
+ get "/projects/#{url_encode project}/repository/files/#{url_encode filepath}/raw",
20
+ query: { ref: ref},
21
+ format: nil,
22
+ headers: { Accept: 'text/plain' },
23
+ parser: ::Gitlab::Request::Parser
24
+ end
25
+ alias_method :repo_file_contents, :file_contents
26
+
7
27
  # Gets a repository file.
8
28
  #
9
29
  # @example
10
30
  # Gitlab.get_file(42, "README.md", "master")
11
31
  #
12
- # @param [Integer] project The ID of a project.
32
+ # @param [Integer, String] project The ID or name of a project.
13
33
  # @param [String] file_path The full path of the file.
14
34
  # @param [String] ref The name of branch, tag or commit.
15
35
  # @return [Gitlab::ObjectifiedHash]
16
36
  def get_file(project, file_path, ref)
17
- get("/projects/#{project}/repository/files", query: {
18
- file_path: file_path,
37
+ get("/projects/#{url_encode project}/repository/files/#{url_encode file_path}", query: {
19
38
  ref: ref
20
39
  })
21
40
  end
@@ -25,14 +44,14 @@ class Gitlab::Client
25
44
  # @example
26
45
  # Gitlab.create_file(42, "path", "branch", "content", "commit message")
27
46
  #
28
- # @param [Integer] project The ID of a project.
47
+ # @param [Integer, String] project The ID or name of a project.
29
48
  # @param [String] full path to new file.
30
49
  # @param [String] the name of the branch.
31
50
  # @param [String] file content.
32
51
  # @param [String] commit message.
33
52
  # @return [Gitlab::ObjectifiedHash]
34
53
  def create_file(project, path, branch, content, commit_message)
35
- post("/projects/#{project}/repository/files", body: {
54
+ post("/projects/#{url_encode project}/repository/files", body: {
36
55
  file_path: path,
37
56
  branch_name: branch,
38
57
  commit_message: commit_message
@@ -44,14 +63,14 @@ class Gitlab::Client
44
63
  # @example
45
64
  # Gitlab.edit_file(42, "path", "branch", "content", "commit message")
46
65
  #
47
- # @param [Integer] project The ID of a project.
66
+ # @param [Integer, String] project The ID or name of a project.
48
67
  # @param [String] full path to new file.
49
68
  # @param [String] the name of the branch.
50
69
  # @param [String] file content.
51
70
  # @param [String] commit message.
52
71
  # @return [Gitlab::ObjectifiedHash]
53
72
  def edit_file(project, path, branch, content, commit_message)
54
- put("/projects/#{project}/repository/files", body: {
73
+ put("/projects/#{url_encode project}/repository/files", body: {
55
74
  file_path: path,
56
75
  branch_name: branch,
57
76
  commit_message: commit_message
@@ -63,13 +82,13 @@ class Gitlab::Client
63
82
  # @example
64
83
  # Gitlab.remove_file(42, "path", "branch", "commit message")
65
84
  #
66
- # @param [Integer] project The ID of a project.
85
+ # @param [Integer, String] project The ID or name of a project.
67
86
  # @param [String] full path to new file.
68
87
  # @param [String] the name of the branch.
69
88
  # @param [String] commit message.
70
89
  # @return [Gitlab::ObjectifiedHash]
71
90
  def remove_file(project, path, branch, commit_message)
72
- delete("/projects/#{project}/repository/files", body: {
91
+ delete("/projects/#{url_encode project}/repository/files", body: {
73
92
  file_path: path,
74
93
  branch_name: branch,
75
94
  commit_message: commit_message
@@ -1,10 +1,10 @@
1
1
  class Gitlab::Client
2
2
  # Defines methods related to runners.
3
- # @see https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/runners.md
3
+ # @see https://docs.gitlab.com/ce/api/runners.html
4
4
  module Runners
5
5
 
6
6
  # Get a list of specific runners available to the user.
7
- # Full runner params documentation: https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/runners.md
7
+ # @see https://docs.gitlab.com/ce/api/runners.html#list-owned-runners
8
8
  #
9
9
  # @example
10
10
  # Gitlab.runners
@@ -19,7 +19,7 @@ class Gitlab::Client
19
19
  end
20
20
 
21
21
  # Get a list of all runners in the GitLab instance (specific and shared). Access is restricted to users with admin privileges.
22
- # Full runner params documentation: https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/runners.md
22
+ # @see https://docs.gitlab.com/ce/api/runners.html#list-all-runners
23
23
  #
24
24
  # @example
25
25
  # Gitlab.all_runners
@@ -32,7 +32,7 @@ class Gitlab::Client
32
32
  end
33
33
 
34
34
  # Get details of a runner..
35
- # Full runner params documentation: https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/runners.md
35
+ # @see https://docs.gitlab.com/ce/api/runners.html#get-runners-details
36
36
  #
37
37
  # @example
38
38
  # Gitlab.runner(42)
@@ -44,7 +44,7 @@ class Gitlab::Client
44
44
  end
45
45
 
46
46
  # Update details of a runner.
47
- # Full runner params documentation: https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/runners.md
47
+ # @see https://docs.gitlab.com/ce/api/runners.html#update-runners-details
48
48
  #
49
49
  # @example
50
50
  # Gitlab.update_runner(42, { description: 'Awesome runner' })
@@ -61,7 +61,7 @@ class Gitlab::Client
61
61
  end
62
62
 
63
63
  # Remove a runner.
64
- # Full runner params documentation: https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/runners.md
64
+ # @see https://docs.gitlab.com/ce/api/runners.html#remove-a-runner
65
65
  #
66
66
  # @example
67
67
  # Gitlab.delete_runner(42)
@@ -73,42 +73,42 @@ class Gitlab::Client
73
73
  end
74
74
 
75
75
  # List all runners (specific and shared) available in the project. Shared runners are listed if at least one shared runner is defined and shared runners usage is enabled in the project's settings.
76
- # Full runner params documentation: https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/runners.md
76
+ # @see https://docs.gitlab.com/ce/api/runners.html#list-projects-runners
77
77
  #
78
78
  # @example
79
79
  # Gitlab.project_runners(42)
80
80
  #
81
- # @param [Integer, String] id The ID of a project.
81
+ # @param [Integer, String] id The ID or name of a project.
82
82
  # @return [Array<Gitlab::ObjectifiedHash>]
83
83
  def project_runners(project_id)
84
- get("/projects/#{project_id}/runners")
84
+ get("/projects/#{url_encode project_id}/runners")
85
85
  end
86
86
 
87
87
  # Enable an available specific runner in the project.
88
- # Full runner params documentation: https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/runners.md
88
+ # @see https://docs.gitlab.com/ce/api/runners.html#enable-a-runner-in-project
89
89
  #
90
90
  # @example
91
91
  # Gitlab.project_enable_runner(2, 42)
92
92
  #
93
- # @param [Integer, String] id The ID of a project.
93
+ # @param [Integer, String] id The ID or name of a project.
94
94
  # @param [Integer, String] id The ID of a runner.
95
95
  # @return <Gitlab::ObjectifiedHash>
96
96
  def project_enable_runner(project_id, id)
97
97
  body = { runner_id: id }
98
- post("/projects/#{project_id}/runners", body: body)
98
+ post("/projects/#{url_encode project_id}/runners", body: body)
99
99
  end
100
100
 
101
101
  # Disable a specific runner from the project. It works only if the project isn't the only project associated with the specified runner.
102
- # Full runner params documentation: https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/runners.md
102
+ # @see https://docs.gitlab.com/ce/api/runners.html#disable-a-runner-from-project
103
103
  #
104
104
  # @example
105
105
  # Gitlab.project_disable_runner(2, 42)
106
106
  #
107
- # @param [Integer, String] id The ID of a project.
107
+ # @param [Integer, String] id The ID or name of a project.
108
108
  # @param [Integer, String] runner_id The ID of a runner.
109
109
  # @return <Gitlab::ObjectifiedHash>
110
110
  def project_disable_runner(id, runner_id)
111
- delete("/projects/#{id}/runners/#{runner_id}")
111
+ delete("/projects/#{url_encode id}/runners/#{runner_id}")
112
112
  end
113
113
 
114
114
  end
@@ -1,4 +1,6 @@
1
1
  class Gitlab::Client
2
+ # Third party services connected to a project.
3
+ # @see https://docs.gitlab.com/ce/api/services.html
2
4
  module Services
3
5
  # Create/Edit service
4
6
  # Full service params documentation: https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/services.md
@@ -8,12 +10,12 @@ class Gitlab::Client
8
10
  # project_url: 'https://example.com/projects/test_project/issues',
9
11
  # issues_url: 'https://example.com/issues/:id' })
10
12
  #
11
- # @param [Integer] project The ID of a project.
13
+ # @param [Integer, String] project The ID or name of a project.
12
14
  # @param [String] service A service code name.
13
15
  # @param [Hash] params A service parameters.
14
16
  # @return [Boolean]
15
17
  def change_service(project, service, params)
16
- put("/projects/#{project}/services/#{correct_service_name(service)}", body: params)
18
+ put("/projects/#{url_encode project}/services/#{correct_service_name(service)}", body: params)
17
19
  end
18
20
 
19
21
  # Delete service
@@ -21,11 +23,11 @@ class Gitlab::Client
21
23
  # @example
22
24
  # Gitlab.delete_service(42, :redmine)
23
25
  #
24
- # @param [Integer] project The ID of a project.
26
+ # @param [Integer, String] project The ID or name of a project.
25
27
  # @param [String] service A service code name.
26
28
  # @return [Boolean]
27
29
  def delete_service(project, service)
28
- delete("/projects/#{project}/services/#{correct_service_name(service)}")
30
+ delete("/projects/#{url_encode project}/services/#{correct_service_name(service)}")
29
31
  end
30
32
 
31
33
  # Get service
@@ -33,11 +35,11 @@ class Gitlab::Client
33
35
  # @example
34
36
  # Gitlab.service(42, :redmine)
35
37
  #
36
- # @param [Integer] project The ID of a project.
38
+ # @param [Integer, String] project The ID or name of a project.
37
39
  # @param [String] service A service code name.
38
40
  # @return [Gitlab::ObjectifiedHash]
39
41
  def service(project, service)
40
- get("/projects/#{project}/services/#{correct_service_name(service)}")
42
+ get("/projects/#{url_encode project}/services/#{correct_service_name(service)}")
41
43
  end
42
44
 
43
45
  private
@@ -1,19 +1,19 @@
1
1
  class Gitlab::Client
2
2
  # Defines methods related to snippets.
3
- # @see https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/project_snippets.md
3
+ # @see https://docs.gitlab.com/ce/api/project_snippets.html
4
4
  module Snippets
5
5
  # Gets a list of project's snippets.
6
6
  #
7
7
  # @example
8
8
  # Gitlab.snippets(42)
9
9
  #
10
- # @param [Integer] project The ID of a project.
10
+ # @param [Integer, String] project The ID or name of a project.
11
11
  # @param [Hash] options A customizable set of options.
12
12
  # @option options [Integer] :page The page number.
13
13
  # @option options [Integer] :per_page The number of results per page.
14
14
  # @return [Gitlab::ObjectifiedHash]
15
15
  def snippets(project, options={})
16
- get("/projects/#{project}/snippets", query: options)
16
+ get("/projects/#{url_encode project}/snippets", query: options)
17
17
  end
18
18
 
19
19
  # Gets information about a snippet.
@@ -21,11 +21,11 @@ class Gitlab::Client
21
21
  # @example
22
22
  # Gitlab.snippet(2, 14)
23
23
  #
24
- # @param [Integer] project The ID of a project.
24
+ # @param [Integer, String] project The ID or name of a project.
25
25
  # @param [Integer] id The ID of a snippet.
26
26
  # @return [Gitlab::ObjectifiedHash]
27
27
  def snippet(project, id)
28
- get("/projects/#{project}/snippets/#{id}")
28
+ get("/projects/#{url_encode project}/snippets/#{id}")
29
29
  end
30
30
 
31
31
  # Creates a new snippet.
@@ -33,7 +33,7 @@ class Gitlab::Client
33
33
  # @example
34
34
  # Gitlab.create_snippet(42, { title: 'REST', file_name: 'api.rb', code: 'some code' })
35
35
  #
36
- # @param [Integer] project The ID of a project.
36
+ # @param [Integer, String] project The ID or name of a project.
37
37
  # @param [Hash] options A customizable set of options.
38
38
  # @option options [String] :title (required) The title of a snippet.
39
39
  # @option options [String] :file_name (required) The name of a snippet file.
@@ -41,7 +41,7 @@ class Gitlab::Client
41
41
  # @option options [String] :lifetime (optional) The expiration date of a snippet.
42
42
  # @return [Gitlab::ObjectifiedHash] Information about created snippet.
43
43
  def create_snippet(project, options={})
44
- post("/projects/#{project}/snippets", body: options)
44
+ post("/projects/#{url_encode project}/snippets", body: options)
45
45
  end
46
46
 
47
47
  # Updates a snippet.
@@ -49,7 +49,7 @@ class Gitlab::Client
49
49
  # @example
50
50
  # Gitlab.edit_snippet(42, 34, { file_name: 'README.txt' })
51
51
  #
52
- # @param [Integer] project The ID of a project.
52
+ # @param [Integer, String] project The ID or name of a project.
53
53
  # @param [Integer] id The ID of a snippet.
54
54
  # @param [Hash] options A customizable set of options.
55
55
  # @option options [String] :title The title of a snippet.
@@ -58,7 +58,7 @@ class Gitlab::Client
58
58
  # @option options [String] :lifetime The expiration date of a snippet.
59
59
  # @return [Gitlab::ObjectifiedHash] Information about updated snippet.
60
60
  def edit_snippet(project, id, options={})
61
- put("/projects/#{project}/snippets/#{id}", body: options)
61
+ put("/projects/#{url_encode project}/snippets/#{id}", body: options)
62
62
  end
63
63
 
64
64
  # Deletes a snippet.
@@ -66,11 +66,11 @@ class Gitlab::Client
66
66
  # @example
67
67
  # Gitlab.delete_snippet(2, 14)
68
68
  #
69
- # @param [Integer] project The ID of a project.
69
+ # @param [Integer, String] project The ID or name of a project.
70
70
  # @param [Integer] id The ID of a snippet.
71
71
  # @return [Gitlab::ObjectifiedHash] Information about deleted snippet.
72
72
  def delete_snippet(project, id)
73
- delete("/projects/#{project}/snippets/#{id}")
73
+ delete("/projects/#{url_encode project}/snippets/#{id}")
74
74
  end
75
75
 
76
76
  # Returns raw project snippet content as plain text.
@@ -78,11 +78,11 @@ class Gitlab::Client
78
78
  # @example
79
79
  # Gitlab.snippet_content(2, 14)
80
80
  #
81
- # @param [Integer] project The ID of a project.
81
+ # @param [Integer, String] project The ID or name of a project.
82
82
  # @param [Integer] id The ID of a snippet.
83
83
  # @return [Gitlab::ObjectifiedHash] Information about deleted snippet.
84
84
  def snippet_content(project, id)
85
- get("/projects/#{project}/snippets/#{id}/raw",
85
+ get("/projects/#{url_encode project}/snippets/#{id}/raw",
86
86
  format: nil,
87
87
  headers: { Accept: 'text/plain' },
88
88
  parser: ::Gitlab::Request::Parser)
@@ -1,6 +1,6 @@
1
1
  class Gitlab::Client
2
2
  # Defines methods related to system hooks.
3
- # @see https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/system_hooks.md
3
+ # @see https://docs.gitlab.com/ce/api/system_hooks.html
4
4
  module SystemHooks
5
5
  # Gets a list of system hooks.
6
6
  #
@@ -1,19 +1,19 @@
1
1
  class Gitlab::Client
2
2
  # Defines methods related to tags.
3
- # @see https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/tags.md
3
+ # @see https://docs.gitlab.com/ce/api/tags.html
4
4
  module Tags
5
5
  # Gets a list of project repository tags.
6
6
  #
7
7
  # @example
8
8
  # Gitlab.tags(42)
9
9
  #
10
- # @param [Integer] project The ID of a project.
10
+ # @param [Integer, String] project The ID or name of a project.
11
11
  # @param [Hash] options A customizable set of options.
12
12
  # @option options [Integer] :page The page number.
13
13
  # @option options [Integer] :per_page The number of results per page.
14
14
  # @return [Array<Gitlab::ObjectifiedHash>]
15
15
  def tags(project, options={})
16
- get("/projects/#{project}/repository/tags", query: options)
16
+ get("/projects/#{url_encode project}/repository/tags", query: options)
17
17
  end
18
18
  alias_method :repo_tags, :tags
19
19
 
@@ -23,14 +23,14 @@ class Gitlab::Client
23
23
  # Gitlab.create_tag(42, 'new_tag', 'master')
24
24
  # Gitlab.create_tag(42, 'v1.0', 'master', 'Release 1.0')
25
25
  #
26
- # @param [Integer] project The ID of a project.
26
+ # @param [Integer, String] project The ID or name of a project.
27
27
  # @param [String] tag_name The name of the new tag.
28
28
  # @param [String] ref The ref (commit sha, branch name, or another tag) the tag will point to.
29
29
  # @param [String] message Optional message for tag, creates annotated tag if specified.
30
30
  # @param [String] description Optional release notes for tag.
31
31
  # @return [Gitlab::ObjectifiedHash]
32
32
  def create_tag(project, tag_name, ref, message='', description=nil)
33
- post("/projects/#{project}/repository/tags", body: { tag_name: tag_name, ref: ref, message: message, description: description })
33
+ post("/projects/#{url_encode project}/repository/tags", body: { tag_name: tag_name, ref: ref, message: message, description: description })
34
34
  end
35
35
  alias_method :repo_create_tag, :create_tag
36
36
 
@@ -40,11 +40,11 @@ class Gitlab::Client
40
40
  # Gitlab.tag(3, 'api')
41
41
  # Gitlab.repo_tag(5, 'master')
42
42
  #
43
- # @param [Integer] project The ID of a project.
43
+ # @param [Integer, String] project The ID or name of a project.
44
44
  # @param [String] tag The name of the tag.
45
45
  # @return [Gitlab::ObjectifiedHash]
46
46
  def tag(project, tag)
47
- get("/projects/#{project}/repository/tags/#{tag}")
47
+ get("/projects/#{url_encode project}/repository/tags/#{tag}")
48
48
  end
49
49
  alias_method :repo_tag, :tag
50
50
 
@@ -54,11 +54,11 @@ class Gitlab::Client
54
54
  # Gitlab.delete_tag(3, 'api')
55
55
  # Gitlab.repo_delete_tag(5, 'master')
56
56
  #
57
- # @param [Integer] project The ID of a project.
57
+ # @param [Integer, String] project The ID or name of a project.
58
58
  # @param [String] tag The name of the tag to delete
59
59
  # @return [Gitlab::ObjectifiedHash]
60
60
  def delete_tag(project, tag)
61
- delete("/projects/#{project}/repository/tags/#{tag}")
61
+ delete("/projects/#{url_encode project}/repository/tags/#{tag}")
62
62
  end
63
63
  alias_method :repo_delete_tag, :delete_tag
64
64
 
@@ -68,12 +68,12 @@ class Gitlab::Client
68
68
  # Gitlab.create_release(3, '1.0.0', 'This is ready for production')
69
69
  # Gitlab.repo_create_release(5, '1.0.0', 'This is ready for production')
70
70
  #
71
- # @param [Integer] project The ID of a project.
71
+ # @param [Integer, String] project The ID or name of a project.
72
72
  # @param [String] tag The name of the new tag.
73
73
  # @param [String] description Release notes with markdown support
74
74
  # @return [Gitlab::ObjectifiedHash]
75
75
  def create_release(project, tag, description)
76
- post("/projects/#{project}/repository/tags/#{tag}/release", body: { description: description })
76
+ post("/projects/#{url_encode project}/repository/tags/#{tag}/release", body: { description: description })
77
77
  end
78
78
  alias_method :repo_create_release, :create_release
79
79
 
@@ -83,12 +83,12 @@ class Gitlab::Client
83
83
  # Gitlab.update_release(3, '1.0.0', 'This is even more ready for production')
84
84
  # Gitlab.repo_update_release(5, '1.0.0', 'This is even more ready for production')
85
85
  #
86
- # @param [Integer] project The ID of a project.
86
+ # @param [Integer, String] project The ID or name of a project.
87
87
  # @param [String] tag The name of the new tag.
88
88
  # @param [String] description Release notes with markdown support
89
89
  # @return [Gitlab::ObjectifiedHash]
90
90
  def update_release(project, tag, description)
91
- put("/projects/#{project}/repository/tags/#{tag}/release", body: { description: description })
91
+ put("/projects/#{url_encode project}/repository/tags/#{tag}/release", body: { description: description })
92
92
  end
93
93
  alias_method :repo_update_release, :update_release
94
94