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
19
20
# File 'lib/yadecli/client/gitlab_client.rb', line 13

def initialize
  Gitlab.configure do |config|
    config.endpoint       = AppConfig[:git_api_url]   # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT']
    config.private_token  = AppConfig[:git_token]     # user's private token or OAuth2 access token, default: ENV['GITLAB_API_PRIVATE_TOKEN']
  end

  #Gitlab.http_proxy('squid.dzbw.de', 3128)
end

Instance Method Details

#get_branch_names(repository_name) ⇒ Object

get branch names from gitlab project given by name



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

def get_branch_names(repository_name)
  projects = Gitlab.projects

  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



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

def get_default_branch(repository_name)
  projects = Gitlab.projects

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

  project.default_branch
end