Class: Yadecli::Client::GitlabClient

Inherits:
Object
  • Object
show all
Defined in:
lib/yadecli/client/gitlab_client.rb

Overview

gitlab client

Instance Method Summary collapse

Constructor Details

#initializeGitlabClient

request yade token



13
14
15
16
17
18
# File 'lib/yadecli/client/gitlab_client.rb', line 13

def initialize
  Gitlab.configure do |config|
    config.endpoint       = Yade::Common::Config::ComposerConfig[:git_api_url]
    config.private_token  = Yade::Common::Config::ComposerConfig[:git_token]
  end
end

Instance Method Details

#get_branch_names(repository_name) ⇒ Object

get branch names from gitlab project given by name



21
22
23
24
25
26
27
28
29
# File 'lib/yadecli/client/gitlab_client.rb', line 21

def get_branch_names(repository_name)
  projects = Gitlab.projects(search: repository_name)

  project = projects.select { |p| repository_name == p.name }.first

  branches = Gitlab.branches(project.id)

  branches.map { |b| b.name }
end

#get_default_branch(repository_name) ⇒ Object

get branch names from gitlab project given by name



32
33
34
35
36
37
38
# File 'lib/yadecli/client/gitlab_client.rb', line 32

def get_default_branch(repository_name)
  projects = Gitlab.projects(search: repository_name)

  project = projects.select { |p| repository_name == p.name }.first

  project.default_branch
end