Class: LabClient::Commits

Inherits:
Common
  • Object
show all
Defined in:
lib/labclient/commits/diff.rb,
lib/labclient/commits/list.rb,
lib/labclient/commits/refs.rb,
lib/labclient/commits/show.rb,
lib/labclient/commits/create.rb,
lib/labclient/commits/revert.rb,
lib/labclient/commits/comments.rb,
lib/labclient/commits/cherry_pick.rb,
lib/labclient/commits/status/list.rb,
lib/labclient/commits/status/update.rb,
lib/labclient/commits/comment_create.rb,
lib/labclient/commits/merge_requests.rb

Overview

Specifics

Constant Summary

Constants included from AccessLevel

AccessLevel::HUMAN_ACCESS_LEVELS, AccessLevel::MACHINE_ACCESS_LEVELS

Instance Attribute Summary

Attributes inherited from Common

#client

Instance Method Summary collapse

Methods inherited from Common

#api_methods, #api_methods_help, #format_id, #format_query_id, #format_query_ids, #format_time?, #group_name, #help, #initialize, #inspect, #klass, #protected_query_access_level, #query_access_level, #query_format_time

Methods included from Docs

#demo, #desc, #doc, docs, #example, #group_name, #help, json, #markdown, #navigation, #option, #result, #subtitle, #title

Methods included from AccessLevel

#human_access_level, #human_protected_access_level, #machine_access_level, #machine_protected_access_level

Constructor Details

This class inherits a constructor from LabClient::Common

Instance Method Details

#cherry_pick(project_id, commit_id, branch_name) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/labclient/commits/cherry_pick.rb', line 32

def cherry_pick(project_id, commit_id, branch_name)
  project_id = format_id(project_id)
  commit_id = format_id(commit_id)
  branch_name = format_id(branch_name)

  client.request(:post, "projects/#{project_id}/repository/commits/#{commit_id}/cherry_pick", Commit, { branch: branch_name })
end

#comment_create(project_id, commit_id, query) ⇒ Object



60
61
62
63
64
65
# File 'lib/labclient/commits/comment_create.rb', line 60

def comment_create(project_id, commit_id, query)
  project_id = format_id(project_id)
  commit_id = format_id(commit_id)

  client.request(:post, "projects/#{project_id}/repository/commits/#{commit_id}/comments", CommitComment, query)
end

#comments(project_id, commit_id) ⇒ Object



32
33
34
35
36
37
# File 'lib/labclient/commits/comments.rb', line 32

def comments(project_id, commit_id)
  project_id = format_id(project_id)
  commit_id = format_id(commit_id)

  client.request(:get, "projects/#{project_id}/repository/commits/#{commit_id}/comments", CommitComment)
end

#create(project_id, query = {}) ⇒ Object



77
78
79
80
81
# File 'lib/labclient/commits/create.rb', line 77

def create(project_id, query = {})
  project_id = format_id(project_id)

  client.request(:post, "projects/#{project_id}/repository/commits", Commit, query)
end

#diff(project_id, commit_id) ⇒ Object



32
33
34
35
36
37
# File 'lib/labclient/commits/diff.rb', line 32

def diff(project_id, commit_id)
  project_id = format_id(project_id)
  commit_id = format_id(commit_id)

  client.request(:get, "projects/#{project_id}/repository/commits/#{commit_id}/diff", CommitDiff)
end

#list(project_id, query = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/labclient/commits/list.rb', line 44

def list(project_id, query = {})
  project_id = format_id(project_id)

  %i[since until].each do |field|
    query[field] = query[field].to_time.iso8601 if format_time?(query[field])
  end

  client.request(:get, "projects/#{project_id}/repository/commits", Commit, query)
end

#merge_requests(project_id, commit_id) ⇒ Object



33
34
35
36
37
38
# File 'lib/labclient/commits/merge_requests.rb', line 33

def merge_requests(project_id, commit_id)
  project_id = format_id(project_id)
  commit_id = format_id(commit_id)

  client.request(:get, "projects/#{project_id}/repository/commits/#{commit_id}/merge_requests", MergeRequest)
end

#refs(project_id, commit_id, scope = :all) ⇒ Object



37
38
39
40
41
42
# File 'lib/labclient/commits/refs.rb', line 37

def refs(project_id, commit_id, scope = :all)
  project_id = format_id(project_id)
  commit_id = format_id(commit_id)

  client.request(:get, "projects/#{project_id}/repository/commits/#{commit_id}/refs", nil, { scope: scope })
end

#revert(project_id, commit_id, branch_name) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/labclient/commits/revert.rb', line 32

def revert(project_id, commit_id, branch_name)
  project_id = format_id(project_id)
  commit_id = format_id(commit_id)
  branch_name = format_id(branch_name)

  client.request(:post, "projects/#{project_id}/repository/commits/#{commit_id}/revert", Commit, { branch: branch_name })
end

#show(project_id, commit_id, query = {}) ⇒ Object

Show



28
29
30
31
32
# File 'lib/labclient/commits/show.rb', line 28

def show(project_id, commit_id, query = {})
  project_id = format_id(project_id)

  client.request(:get, "projects/#{project_id}/repository/commits/#{commit_id}", Commit, query)
end

#status(project_id, commit_id, query = {}) ⇒ Object



50
51
52
53
54
55
# File 'lib/labclient/commits/status/list.rb', line 50

def status(project_id, commit_id, query = {})
  project_id = format_id(project_id)
  commit_id = format_id(commit_id)

  client.request(:get, "projects/#{project_id}/repository/commits/#{commit_id}/statuses", CommitStatus, query)
end

#status_update(project_id, commit_id, query = {}) ⇒ Object



46
47
48
49
50
51
# File 'lib/labclient/commits/status/update.rb', line 46

def status_update(project_id, commit_id, query = {})
  project_id = format_id(project_id)
  commit_id = format_id(commit_id)

  client.request(:post, "projects/#{project_id}/statuses/#{commit_id}", CommitStatus, query)
end